/ ************************ /
/ * CC2530 routines /
/ Routine Name: Timer (query) /
/ Description: by timer T1 query mode controls LED1 to flash periodically
/
#include <ioCC2530.h>
#define uint unsigned int
#define uchar unsigned char
#define LED1 P1_0 //Define LED1 as P1_0 port control
//Function declaration
void InitLed(void); // P1 port initialization
void InitT1 (); // initialize the timer Tl
// initialization program
/ /
void InitLed (void)
{ P1DIR | = 0x01; // P1_0 defined as output LED1 = 0; // LED1 lights off initialization } // Timer initialization void InitT1() //When the system does not configure the working clock, the internal RC oscillator is used by default, that is, 16MHz { T1CTL=0x0E; //128 frequency division, analog mode
T1CC0L=0x12;
T1CC0H=0x7A;
T1CCTL0 |= 0x04; //Enable the output comparison mode of channel 0
}
/
- Function name: main
- Function: main function entrance
- Entry parameters: none
- Export parameters: none
- Return value: None
*****************************/
void main(void)
{ uchar count; InitLed(); //Call the initialization function InitT1(); while(1) { if(T1STAT&0x21==0x21) { T1STAT&=~0x21; ++count; } if(count == 6) //If the overflow count reaches 6, it means that 1.5 seconds have passed { LED1 = 1 ; //Turn on LED1 } if(count == 8) //If the overflow count reaches 8, it means 2 seconds have passed { LED1 = 0; //Turn off LED1 count=0; } } }