/* ========================================================================== */ /* */ /* tmr.c */ /* (c) 2006 ICPDAS_EVA_LI */ /* */ /* Timer & WDT */ /* */ /* ========================================================================== */ #include #include void main() { unsigned long time; int quit=0; InitLib(); Print("\n\rPress any key to start timer"); Print("\n\rthen Press '0' to Reset timer,'1'~'4' to delay, 'q' to quit\n\r"); Getch(); TimerOpen(); while(!quit){ /*set the key function*/ if(Kbhit()){ switch(Getch()){ case '0': TimerResetValue(); break; case '1': DelayMs(1000); /* delay unit is ms, use system timeticks. */ break; case '2': Delay(1000); /* delay unit is ms, use CPU Timer 1. */ break; case '3': Delay_1(1000); /* delay unit is 0.1 ms ,use CPU Timer 1.*/ break; case '4': Delay_2(1000); /* delay unit is 0.01 ms ,use CPU Timer 1.*/ break; case 'q': quit=1; break; } } time=TimerReadValue(); Print("\r\nTime=%8.3f sec",0.001*time); } TimerClose(); }