/* DEMO92.c: Using the StopWatch timer to toggle the LED at regular intervals of approximately 500 ms. Compiler: BC++ 3.1, Turbo C++ 1.01 (3.01), MSVC 1.52 Compile mode: Large Project: DEMO92.c ..\..\Lib\upac5000.lib Hardware: uPAC-5000 Description TimerOpen(): Starts the timer. TimerClose(): Stops the timer. If TimerOpen() is called within your program, it must call TimerClose() before exiting. StopWatchStart(): Starts a StopWatchTimer of the specified timer channel, and reset the StopWatchTimer to zero. StopWatchReadValue(): Reads the current value of StopWatchTimer. [Dec 21, 2011] by Liam */ #include #include "..\..\lib\upac5000.h" void main(void) { unsigned long value; int quit=0; InitLib(); /* InitLib() must be called before other functions in the library may be used */ Print("\r\nPress 'q' to quit\r\n"); TimerOpen(); StopWatchStart(0); while(!quit) { if(Kbhit() && Getch()) quit=1; StopWatchReadValue(0, &value); if(value>=500) { /* Toggle the LED at regular intervals of approximately 500 ms */ StopWatchStart(0); LedToggle(); } } TimerClose(); }