/* DEMO91.C Demonstration for use Timer functions. use CountDownTimer channel 0 for all od the LED ON/OFF */ #include #include void main(void) { int LedMode=0; unsigned long value; int quit=0; unsigned Ver; 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(); 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; outp(LED_PORT,LED_F1 | LED_F2 | LED_F3| LED_F4 | LED_PWR | LED_RUN |LED_SHIFT); } else { LedMode=1; outp(LED_PORT,0); } } } TimerClose(); LedOn(); }