/* TimeTick.c : to demonstrate how to use GetTimeTicks() 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: TimeTick.c ..\..\Lib\(8000E.Lib,7188XAL.Lib,7188XBL.Lib,7188XCL.Lib or 7188EL.Lib) Hardware: 7188/8000 Detail description: GetTimeTicks() is a global variable for system timeticks extern const unsigned long far *const TimeTicks; the usage of GetTimeTicks() is the same as GetTickCount() function of windows function. [1 Jun,2006] by martin */ #include "..\..\lib\8000E.h" void Message(void); void INC(void); unsigned long loopCnt=0; unsigned long tickCnt; int ControlFlag=0; unsigned long DOdata[2]={0,1}; void main() { int iSlot,DOIndex; long i,val; tickCnt=GetTimeTicks(); // begin timer count iSlot=0; DOIndex=0; /* for(i=0;i<100000;i++) // do something { loopCnt++; } Print("loopCnt++ 100000 times need:%lu ms \n\r",GetTimeTicks()-tickCnt); // calcutlate the time */ for(;;) // example for using TimeTick as loop control { if(ControlFlag==0) { //tickCnt=GetTimeTicks(); //loopCnt++; ControlFlag=1; } else { if(GetTimeTicks()-tickCnt>=5) { DOIndex=1-DOIndex; //Print("LoopCnt:%lu\n\r",loopCnt); DO_16(iSlot,DOdata[1-DOIndex]); tickCnt=GetTimeTicks(); ControlFlag=0; } } } } void INC(void) { loopCnt++; } void Message(void) { Print("LoopCnt:%lu\n\r",loopCnt); }