📄 timer-adc-uart_test.c
字号:
/******************************************************************************
Filename: int_timer.c
Target: cc2430
Revised: 16/12-2005
Revision: 1.0
Description:
Timer 1,2 and 3 are configured to run and generate interrupts. Each timer
is associated with an asterisk on the LCD.
******************************************************************************/
#include "app_ex.h"
// Prototypes
void int_timer_main(void);
//void int_timer_init(APPLICATION *a);
void int_timer_T1_IRQ(void);
void int_timer_T2_IRQ(void);
void int_timer_T3_IRQ(void);
void int_timer_T4_IRQ(void);
void timer_int_main(void);
INT16 seven,six;
int i;
INT16 destString[56];
_Bool t1 = 0;
_Bool t2 = 0;
_Bool t3 = 0;
UINT16 t1Val = 0;
UINT16 t3Val = 0;
/******************************************************************************
* @fn timer_int_main
*
* @brief
* Main function.
*
* Parameters:
*
* @param void
*
* @return void
*
******************************************************************************/
#ifdef COMPLETE_APPLICATION
void timer_int_main(void){
#else
void main(void){
#endif
// UINT8 timer3Period;
UINT16 timer1Period;
SET_MAIN_CLOCK_SOURCE(CRYSTAL);
initUART();
// Enabling overflow interrupt from timer 1
TIMER1_INIT(); //清除timer1相关寄存器和中断关闭
timer1Period = halSetTimer1Period(5000); //200Hz
if(timer1Period != 0)
{
TIMER1_ENABLE_OVERFLOW_INT(TRUE);
INT_ENABLE(INUM_T1, INT_ON);
TIMER1_RUN(TRUE);
}
INT_GLOBAL_ENABLE(TRUE);
// Running until the application is stopped.
while(1);
}
/******************************************************************************
* @fn int_timer_T1_IRQ
*
* @brief
* Interrupt handler for timer T1 interrupts.
*
* Parameters:
*
* @param void
*
* @return void
*
******************************************************************************/
#ifdef COMPLETE_APPLICATION
void int_timer_T1_IRQ(void){
#else
#pragma vector=T1_VECTOR
__interrupt void T1_IRQ(void){
#endif
//只用这一句就可以单次采样
seven = halAdcSampleSingle(ADC_REF_AVDD, ADC_14_BIT, ADC_AIN7); //单个变量seven的值是不能在watch窗口中被观察到的
// six = halAdcSampleSingle(ADC_REF_AVDD, ADC_14_BIT, ADC_AIN6);
printf("%d ",seven);
// halWait(5); //用于观察,否则执行下一句程序结束,则watch窗口里面就什么也没有了
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -