#include #define uchar unsigned char#define uint unsigned int__CONFIG(0X3B32);#define LED PORTDchar Counter = 0; // 1S计数变量清零/********定时器0初始化函数********/void timer0_init(){ OPTION_REG=0b00000111; //TMR0对内部时钟计数,预分频器给TMR0,分频比为1:256INTCON=0b10100000; //允许TMR0溢出中断TMR0=61; //TMR0赋初值,定时10ms}/********主函数********/void main(void){TRISD=0x00; //设PORTD为输出timer0_init();LED=0x00; while(1); //原地等待}/********中断服务程序********/void interrupt ISR(void){ if (T0IF==1){T0IF=0; //清TMR0溢出中断标志位TMR0=61; //TMR0赋初值,必须!if(++Counter >= 100) //定时时间到1S吗?定时中断溢出100次为1S{LED=~LED;Counter = 0; //1S计时变量清零}}}