/* DEMO90.c: A demonstration program showing how to use the Timer function. **press '0' to reset timer. **press 'q' to quit program. Compiler: BC++ 3.1, Turbo C++ 1.01 (3.01), MSVC 1.52 Compile mode: large Project: DEMO90.c ..\..\Lib\upac5000.lib Hardware: uPAC-5000 Description You can use timer functions to time program execution by calling the member functions start and stop within your program, and then using TimerReadValue() to return the elapsed time. Max. TimerValue: 4,294,967,295 ms (0xFFFFFFFF) = 4,294,967.295 sec = 49.7 days TimerOpen(): Starts the timer. TimerClose(): Stops the timer. If TimerOpen() is called within your program, it must call TimerClose() before exiting. TimerReadValue(): Returns the elapsed time. The time unit for ticks is 1 ms. TimerResetValue(): Resets the elapsed time to zero. The accumulated elapsed time is preserved until a TimerResetValue() call. [Dec 21, 2011] by Liam */ #include #include #include "..\..\lib\upac5000.h" void main(void) { unsigned long time, sec; unsigned sec1; int quit=0; InitLib(); /* InitLib() must be called before other functions in the library may be used */ Print("cos(0)=%f sin(45)=%f\r\n", cos(0), sin(3.14159/4.0)); Print("Press any key to start timer\r\n"); Print("Press '0' to reset timer, 'q' to quit\r\n"); Getch(); TimerOpen(); while(!quit) { if(Kbhit()) { switch(Getch()) { case '0': TimerResetValue(); break; case 'q': quit=1; break; default: break; } } time=TimerReadValue(); Print("\rTime=%8.3f sec", 0.001*time); } TimerClose(); }