兄弟,火气不要那么大。
我用timer2定时过3小时,差20S左右,你想要的话拿去参考一下
//100ms中断一次
void Timer2_Init(void)
{
TIMER2_DIV_128;
TIMER2_Auto_Reload_Delay_Mode;
RCMP2L = 65536-12500;
RCMP2H = (65536-12500)>>8;
TL2 = 0;
TH2 = 0;
set_ET2; // Enable Timer2 interrupt
set_EA;
set_TR2; // Timer2 run //Timer0 run
}
void Timer2_ISR (void) interrupt 5
{
static u16 timer_count1=0,timer_count2=0;
clr_TF2; //Clear Timer2 Interrupt Flag
timer_count1++;
if(timer_count1>=1000)
{
timer_count1=0;
timer_count2++;
if(timer_count2>=108)
{
timer_count2=0;
_3hour_flag=1;
}
}
}
|