Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to analyze the time accuracy of Wince

Shulou Source: shulou.com Published: 2022-06-01 18:42:05 09月24日 Update

How to analyze the time accuracy of Wince, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

GetSystemTime () or GetLocalTime () is accurate to seconds at most in wince, because in embedded systems, the time of the system is maintained by RTC (usually a hardware logic within CPU), which is measured in seconds and is timed by adding 1 per second. So its exact range can only be up to seconds. You can see the implementation of the OEMGetRealTime () function in many BSP KERNEL. When you call API:GetSystemTime () or GetLocalTime (), KERNEL will call the OEMGetRealTime () function to return the result. In OEMGetRealTime (), for the above reasons, ms=0. So you can only get second-level accuracy.

I don't know how this function is implemented on PC, but it must be hardware-related.

A CPU will also have a logic function called OSTimer, which can provide timing similar to RTC, but with millisecond precision. In WINCE, KERNEL has a CurMSec variable that saves how long the system has been running since it was started in milliseconds. In fact, the variable CurMSec is calculated by OSTIMER. When you call GetTickCount (), the system will return the value of CurMSec to you. You can get a time difference by calling GetTickCount () before and after doing an action, that is, the time it takes you to perform this action, which is millisecond precision.

WINCE microsecond and millisecond delay function

/ / WINCE microsecond delay function

Void delay_us (int n) {

LARGE_INTEGER litmp

LONGLONG QPart1,QPart2

Double dfMinus, dfFreq, dfTim

If (QueryPerformanceFrequency (& litmp) = = FALSE)

{

MessageBox (NULL,TEXT ("Error:QueryPerformanceFrequency"), TEXT ("Error"), MB_OK)

Return

}

DfFreq = (double) litmp.QuadPart

QueryPerformanceCounter & litmp)

QPart1 = litmp.QuadPart

Do

{

QueryPerformanceCounter & litmp)

QPart2=litmp.QuadPart

DfMinus= (double) (QPart2-QPart1)

DfTim=dfMinus/dfFreq

} while (dfTim

Tags: Function time precision system precision clarity action unit variable hardware logic help problem content function reason can be passed actually for this Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information MySQL NVidia MariaDB Huawei