} Ram_init(); while(1) { if(TimeFlag) { TimeFlag=0; Time_Fun(); //基准时间函数 } _clrwdt(); _nop_(); } }
//*****************************************************************// // 时间走时函数 // //*****************************************************************// void Work_Fun(void) { }
//*****************************************************************// // 时间走时函数 // //*****************************************************************// void Time_Fun(void) { static u8 Time_4ms_Cnt = 0,Time_10ms_Cnt = 0,Time_100ms_Cnt 0,Time_250ms_Cnt = 0; static u8 Buzz_Cnt=0;
//***************充放电判断********************* LedDisplay(); Time_4ms_Cnt ++; if(Time_4ms_Cnt>=2) { Time_4ms_Cnt=0; AD_fun(); } Time_10ms_Cnt ++; if(Time_10ms_Cnt>=5) { Time_10ms_Cnt=0; KeyDataProcess(); }
=
Time_100ms_Cnt++; if(Time_100ms_Cnt>=50) { Work_Fun(); Time_100ms_Cnt=0; } }
//*****************************************************************// // 中断函数 // //*****************************************************************// void Timer0_ISR(void) interrupt ISRTimer0 // Vector @ 0x0B { static u8 Time2MS = 0; Time2MS ++; if(Time2MS >= 16) //2MS中断函数 { Time2MS = 0; TimeFlag = 1; } if(Buzz_Flag) BUZZ=!BUZZ; else BUZZ=0;
//*************************************** }
void Timer1_ISR(void) interrupt ISRTimer1 // Vector @ 0x1B { ; }