/* DEMO91.c: Shows how to use the CountDownTimer function on channel 0 to switch the LED ON or OFF Compiler: BC++ 3.1, Turbo C++ 1.01(3.01) (free from http://cc.codegear.com/free/cpp) MSC 6.0, MSVC 1.52. Compile mode: Large Project: DEMO91.c ..\..\Lib\(8000e.Lib, 7188el.Lib or 7186el.Lib) Hardware: i-7188/uPAC-7186/i-8000 Note: Function used: TimerOpen --> begin to use uPAC-7186 timer TimerClose --> stop to use timer CountDownTimerStart --> start to countdown a time interval CountDownTimerReadValue -->to decide if time is up. Use CountDownTimer to count 500ms(0.5s) to turn LED ON or OFF. [Oct 30, 2008] by Liam */ #include #include "..\..\lib\7186e.h" void main(void) { int LedMode=0; unsigned long value; int quit=0; InitLib(); Print("Test StopWatch ...\r\n"); Print("Now LED must flash once every second\r\n"); Print("\r\nPress 'q' to quit\r\n"); TimerOpen(); LedOff(); CountDownTimerStart(0, 500); while(!quit) { if(Kbhit()) { switch(Getch()) { case 'q': quit=1; break; } } CountDownTimerReadValue(0, &value); if(value==0) { CountDownTimerStart(0, 500); if(LedMode) { LedMode=0; LedOff(); } else { LedMode=1; LedOn(); } } } TimerClose(); LedOn(); }