CC2530————T3 timer query method to control LED lights

/ T3 timer is an 8-bit timer */
#include<iocc2530.h>
#define LED1 P1_5
#define LED2 P1_0
#define LED3 P1_3
#define LED4 P1_4
#define uchar unsigned char
#define uint unsigned int
uchar count=0;
void Initial(void)
{ P1SEL&=~0X39; P1DIR|=0X39; P1&=~0X39; } void InitT3(void) { T3CTL|=0XE0;//Select the frequency, corresponding to the upper 3 bits of the 8 bits //(0.5/ 128/16) 1024 1024 T3CTL&=~0X03;//The mode is free mode, corresponding to 0 and 1 of 8 bits, 65535*8/1024/1024=0.5s //65536/255=257 T3CTL|=0x10; //Start bit//corresponding to the 4th bit of the 8 bits } main() { Initial(); InitT3();















while(1)
{ if(IRCON>0) { IRCON=0; count++; } if(count>245)//245 is one cycle, which is 0.5s { count=0; LED2=LED3=LED4=0; LED1= !LED1; } } }












Guess you like

Origin blog.csdn.net/News53231323/article/details/113187129