/* DEMO91.c: Using the CountDown Timer functions 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: DEMO91.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. CountDownTimerStart(): Starts the CountDown Timer. CountDownTimerReadValue(): Reads the current value of CountDown timer. [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(); CountDownTimerStart(0, 500); while(!quit) { if(Kbhit()) { switch(Getch()) { case 'q': quit=1; break; default: break; } } CountDownTimerReadValue(0, &value); if(value==0) { /* Toggle the LED at regular intervals of approximately 500 ms */ CountDownTimerStart(0, 500); LedToggle(); } } TimerClose(); }