Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to analyze the time accuracy of Wince

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report