生成代码,在SC_it.c文件中找到定时器3的中断服务函数,在中断服务函数内部添加如下代码:其中LED_TOGGLE是自己实现的一个宏,就是对LED的翻转操作。 - void Timer3Interrupt() interrupt 13
- {
- /*<UserCodeStart>*/
- static unsigned int count = 0;
- TXINX = 0x03; //选择定时器T3
- TFX = 0; //溢出清零
- count++;
- if(count == 500)
- {
- count = 0;
- LED_TOGGLE;
- }
- /*<UserCodeEnd>*/
- /*Timer3_it write here*/
- }
|