/* 1. Compiler: TC 2.0 2. Mode: Large 3. Project: Demo91.prj Demo91.c ..\lib\8000l.lib ..\lib\tcpipl.lib 4. Explain: 1.Demonstration for use Timer functions. 2.To use CountDownTimer channel 0 for LED ON/OFF. 5. Hordware: 8831 It's compiled by Tony -------------------------------------------------------------------- */ #include #include #include #include #include #include"..\LIB\8000.h" #include"..\LIB\vxcomm.h" /*--------------------------------------------------------------------*/ void main(void) { int LedMode=0; unsigned long value; int quit=0; unsigned Ver; if(!Is8000()){ /*detect the current operation system*/ Print("\ndemo91.exe must run on I-8000 with MiniOS7"); return; } Ver=GetLibVersion(); Print("\n\rLib version=%d.%02d",Ver>>8,Ver&0xff); Print("\n\rTest CountDownTimer..."); Print("\n\rNow LED must flash once every second"); Print("\n\rPress 'q' to quit\n\r"); TimerOpen(); SetLedL1(LED_OFF); 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; SetLedL1(LedMode); Print("\rLed:L1 Off"); } else { LedMode=1; SetLedL1(LedMode); Print("\rLed:L1 On"); } } } TimerClose(); SetLedL1(LED_ON); Print("\rLed:L1 On\n\r"); }