/* newTimer.c : to demonstrate how to use InstallUserTimerFunction_us Compiler: BC++ 3.1, Turbo C ++ 1.01(3.01) (free from http://community.borland.com/museum) MSC 6.0, MSVC 1.52. Compile mode: large Project: Newtimer.c ..\..\Lib\(8000E.Lib,7188XAL.Lib,7188XBL.Lib,7188XCL.Lib or 7188EL.Lib) Hardware: 7188/8000 Detail description: The InstallUserTimerFunction_us (time unit is 0.1 us) and InstallUserTimerFunction_ms (time unit is 1 ms) are use timer Interrupt to trigger the routine function. call StopUserTimerFun to stop the timerfunction Note1: Only one of the InstallUserTimerFunction_us or InstallUserTimerFunction_ms can be Installed in program. Note2: If the triggered routine function must use 10 ms to finish the work, then the timer span must > 10 ms. Note3: Although the The InstallUserTimerFunction_us time unit is 0.1 us, the minimum timer span can not be too small, or the CPU will be always interrupted by the timer [1 Jun,2006] by martin ---------------------------------------------------------------------- */ #include "..\..\lib\P821.h" unsigned long loopCnt=1; void INC(void); void main() { InitLib(); InstallUserTimerFunction_ms(10,INC); //begin UserTimerFunction time unit is 1 ms. Print("Start Timer Function...\n\r"); for(;;) { if(loopCnt%100==0) { Print("\nLoopCnt:%lu\n\r",loopCnt); } else { Print("%lu*********\r",loopCnt); } if(loopCnt>=1500) { Print("Stop Timer Function...\n\r"); Delay(10); // Delay 10 ms to print message break; //break to exit the endless loop function } } } void INC(void) { loopCnt++; if(loopCnt>=1500) { StopUserTimerFun(); // Stop the UserTimerFunction } }