#define MAIN_Fosc 33176600L //定义主时钟
#define Timer0_Reload (65536 -(MAIN_Fosc / 1000)) //Timer 0 中断频率, 1000次/秒
AUXR = 0x80; //Timer0 set as 1T, 16 bits timer auto-reload,
TH0 = (unsigned char)(Timer0_Reload / 256);
TL0 = (unsigned char)(Timer0_Reload % 256);
ET0 = 1; //Timer0 interrupt enable
TR0 = 1; //Tiner0 run
EA = 1; //打开总中断
void timer0 (void) interrupt 1
{
B_1ms = 1; //1ms标志
P10=!P10;
}
不管定时器初值给多少,P10的频率都是65hz
|