我的定时器0设置如下,但是运行时如法进入中断,难道设置有错误??
void timer0_init(void) { rSRCPND = rSRCPND | (0x1<<10); //清空定时器0源请求 rINTPND = rINTPND | (0x1<<10); //清空定时器0中断请求 rINTMSK = rINTMSK & ~(0x1<<10); //打开定时器0中断 //定时器0输入时钟频率 = PCLK/(预分频值+1)/(分频值),即25KHz=50MHz/(250*8)=50MHz/(2000) rTCFG0 = (rTCFG0 & ~(0xff)) | 249; // prescaler1=249 rTCFG1 = (rTCFG1 & ~(0x0f)) | (0x2); //divider:8,0b0010 rTCNTB0 = 25000; //让定时器0每隔1秒中断一次,则写入寄存器的数值为25000=25kHz/1Hz rTCON =( rTCON & ~(0x0F) ) | (0xA); //自动重载?输出不取反,手动更新、启动定时器0 rTCON = rTCON & ~(0x2); //关闭手动更新 }
|