/* stopwatch.c: Use StopWatch . 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: stopwatch.c ..\..\Lib\(8000E.Lib,7188XAL.Lib,7188XBL.Lib,7188XCL.Lib or 7188EL.Lib) Hardware: 7188/8000 Note: Function used: TimerOpen --> begin to use timer TimerClose --> stop to use timer StopWatchStart(i); --> start or reset stopwatch, Note: i :0~7 there are toatal 8 channel stopwatch timers StopWatchReadValue -->to decide if time is up. Use StopWatch to count 1000(1s) to Reset StopWatch. [01/Jun/2006] compiled by martin */ #include #include"..\..\lib\P821.h" /* you must change this lib to suit the hardware that you want to use. */ void main(void) { int i; unsigned long value[8]; int quit=0; InitLib(); Print("\n\rTest StopWatch ..."); Print("\n\rPress 'q' to quit\n\r"); TimerOpen(); for(i=0;i<4;i++) StopWatchStart(i); while(!quit) { if(Kbhit()) { switch(Getch()) { case 'q': quit=1; break; } } for(i=0;i<4;i++) StopWatchReadValue(i,value+i); if(value[0]>=1000) { StopWatchStart(0); Print("[%04lu]:Reset StopWatch 0 Again!\n",value[0]); } if(value[1]>=2000) { StopWatchStart(1); Print("[%04lu]:Reset StopWatch 1 Again!\n",value[1]); } if(value[2]>=4000) { StopWatchStart(2); Print("[%04lu]:Reset StopWatch 2 Again!\n",value[2]); } if(value[3]>=8000) { StopWatchStart(3); Print("[%04lu]:Reset StopWatch 3 Again!\n",value[3]); } //Print(" test "); } TimerClose(); Print("Timer Closed!\n"); Delay(10); // wait for printing message }