Compartilhar via


Implementing the Real-Time Clock and System Timer (Windows CE 5.0)

Send Feedback

Windows CE provides a variety of functions that your OAL can use to manage time. These functions fall into two categories: real-time clock functions and system-timer functions.

Implementing Real-Time Clock Functions

Real-time clock functions manage time-of-day information. The file Rtc.c, located in %_WINCEROOT%\Platform\Common\Src\Common\RTC\Timer, defines the interfaces that Windows CE uses to communicate with the kernel and the real-time clock.

The following table shows the functions that you must implement on hardware platforms that provide the time of day to the user.

Function Description
OEMGetRealTime Gets the system time.
OEMSetRealTime Sets the system time.
OEMSetAlarmTime Sets the alarm time.

You can also use the IOCTL_HAL_INIT_RTC I/O control code in a call to KernelIoControl to force real-time clock initialization. For more information about how to set the real-time clock, see Setting the Real-Time Clock.

OEMGetRealTime is called by GetSystemTime when the clock is running in hardware mode. In hardware mode, OEMGetRealTime queries the RTC. Alternatively, you can run the clock in software mode by setting a registry key. In software mode, a clock is simulated in software based on GetTickCount, which tracks clock ticks using the timer. To specify software mode for the clock, set HKEY_LOCAL_MACHINE\Platform\"SoftRTC" = 1. This registry key must be set at boot time to have any effect.

Implementing the System-Timer Functions

To query the system timer, Windows CE provides the GetTickCount function. Windows CE also provides a prototype implementation of the system-timer interrupt service routine (ISR).

The OAL system-timer function, SC_GetTickCount, returns the current number of milliseconds since boot. Windows CE calls SC_GetTickCount in your OAL when the Microsoft Win32® function GetTickCount is called. You must register the system-timer interrupts in OEMInit to ensure the system timer is updated appropriately.

Each sample OAL provides a sample implementation of the system-timer ISR. Each time the interrupt goes off, the ISR should reset the hardware and increment the variable CurMSec by one millisecond.

See Also

How to Develop an OEM Adaptation Layer

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.