/* DEMO91.c: Use CountDownTimer channel 0 for LED ON/OFF 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: DEMO91.c ..\..\Lib\(7188XAL.Lib,7188XBL.Lib,7188XCL.Lib or 7188EL.Lib) Hardware: 7188 Note: Function used: TimerOpen --> begin to use I-7188 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. [02/Nov/2005] compiled by Liam */ #include #include"..\..\lib\7188xb.h" /* you must change this lib to suit the hardware that you want to use. */ void main(void) { int LedMode=0; unsigned long value; int quit=0; Print("\n\rTest CountDownTimer..."); Print("\n\rNow LED must flash once every second"); Print("\n\rPress 'q' to quit\n\r"); 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(); }