/* DEMO90.c: It¡¦s the demonstration for using Timer function. **press '0' to reset timer. **press 'q' to quit program. 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: DEMO90.c ..\..\Lib\(7188XAL.Lib,7188XBL.Lib,7188XCL.Lib or 7188EL.Lib) Hardware: 7188 Note: Timer function used : TimerOpen--> begin to use I-7188 timer TimerClose-->Stop to use timer TimerReadValue--> get current timer value.(unit 1ms) TimerResetValue--> reset timer value to 0. This program show the time interval from call TimerOpen or TimerResetValue to now. Max TimerValue=0xFFFFFFFF=4294967295(ms)-->4294967.295(S)-->49.7(days) [02/Nov/2005] compiled by Liam */ #include #include #include"..\..\lib\7188xb.h" /* you must change this lib to suit the hardware that you want to use. */ void main(void) { unsigned long time, sec; unsigned sec1; int quit=0; Print("cos(0)=%f sin(45)=%f", cos(0), sin(3.14159/4.0)); Print("\n\rPress any key to start timer"); Print("\n\rthen Press '0' to Reset timer, 'q' to quit\n\r"); Getch(); TimerOpen(); while(!quit) { if(Kbhit()) { switch(Getch()) { case '0': TimerResetValue(); break; case 'q': quit=1; break; } } time=TimerReadValue(); /* sec=time/1000; sec1=time%1000; printCom3("\rTime=%05ld.%03d sec",sec,sec1); */ Print("\rTime=%8.3f sec",0.001*time); } TimerClose(); }