Unable to get milliseconds from GetSystemTime()

1.4k views Asked by At

I am trying to print out seconds and milliseconds resolution timing and i am using GetSystemTime().

This is my code:

GetSystemTime(&datetime);
RETAILMSG(1,(_T("Time After Data Sent to USB: %d:%d\r\n"), datetime.wSecond, datetime.wMilliseconds));  

I print to the platform builder debug output using RETAILMSG(), but i am only able to print up to seconds resolution, so i will see something like 48:0 where the milliseconds is blank.

I am not sure why this is happening as i receive no complaints. I figure it has something to do with the implementation of RETAILMSG().

Is there a fix for this or a substitute that i can use to achieve milliseconds resolution?

Thanks,

EDIT: I am developing in Windows Embedded Compact 7

2

There are 2 answers

3
Christophe On BEST ANSWER

Under windows, the clock resolution is around 15ms.

If you need millisecond resolution, there is a high performance clock that enables you to measure timebelow 10µs range (see here: Acquiring high-resolution time stamps on msdn).

0
Remy Lebeau On

the milliseconds is blank.

I am not sure why this is happening

The Embedded Compact documentation for GetSystemTime() states the following warning about that issue:

Millisecond granularity may not be supported by a hardware platform. The caller of this function should not rely on more than second granularity.