Implementing the Real-Time Clock and System Timer

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\<Platform>\Kernel\Hal\<Microprocessor>, 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 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.

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 platform 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

Last updated on Wednesday, April 13, 2005

© 2005 Microsoft Corporation. All rights reserved.