On Thursday, June 04, 1998 0:19, Kevin Timmerman[SMTP:opossum@EGL.NET] wrote: > > My problem is that, i want to have fixed clocks, > > independent of machine, to talk with > > DS1307. I have done a "delay" routine with "FOR" command, but > > i think that's not correct! > > > > Can someone say me how i do short 'delays' in > > WINDOWS? (500us) for example! > > > > The GetTickCount() kernal function provides 1ms resolution on Windows > 95/98/NT. > > From the Visual C++ docs.... > > The GetTickCount function retrieves the number of milliseconds that have > elapsed since Windows was started. > > DWORD GetTickCount(VOID) > > Parameters > This function has no parameters. > > Return Value > If the function succeeds, the return value is the number of milliseconds > that have elapsed since Windows was started. > > Remarks > The internal timer wraps around to zero if Windows is run continuously for > approximately 49.7 days. > The GetTickCount function is identical to the GetCurrentTime function. > Applications should use the GetTickCount function because its name matches > more closely what the function does. GetTickCount() granularity is 18ms although the result comes in ms. The fuctions to use is QueryPerformanceFrequency and QueryPerformanceCounter. With this two you get a resolution of micro-seconds or better. They work in win95 and winnt. Try this C code: LARGE_INTEGER freq, antes, depois; BOOL rr = QueryPerformanceFrequency(&freq); QueryPerformanceCounter(&antes); /* elapsed time */ QueryPerformanceCounter(&depois); printf("tempo %g\n", ((double)(depois.QuadPart-antes.QuadPart))/freq.QuadPart); Best Regards, Paulo Soares psoares@consiste.pt