Home |
RTTarget-32 Programming Manual Running Win32 Programs without Win32 Running a Program on the Target Win32 Date and Time Management Win32 Thread Local Storage (TLS) Win32 API Function Cross Reference Alternate Heap Manager RTTHeap Compiling and Linking with On Time RTOS-32 |
Win32 Date and Time ManagementFunction GetTickCount is fully supported and returns the number of elapsed milliseconds since GetTickCount was first called. RTTarget-32 expects an interrupt to occur at 18.2 Hertz on IRQ 0 for this feature to work. The RTTarget-32 boot code usually initializes the timer hardware to generate such a timer interrupt. The interrupt handler is installed by function GetTickCount the first time it is called. If a timer frequency other than 18.2 Hz is used, the calibration constant RTTickFactor must be assigned the actual number of milliseconds per timer interrupt multiplied by 65536 before GetTickCount is called the first time. Example (for 10ms timer interrupt):RTTickFactor = 10 * 65536; Assigning a value to RTTickFactor does not reprogram the timer chip; it merely informs RTTarget-32 of the time interval between two consecutive timer interrupts. If used, RTKernel-32 overrides RTTarget-32's GetTickCount function. RTKernel-32 does not support RTTickFactor. Its GetTickCount function and timer interrupt management is implemented through the RTKernel-32 clock driver and module Clock. RTTarget-32 supports the local date and time functions Get/SetLocalTime. After program reset, the Win32 date and time must be initialized at least once. This is achieved with Win32 function SetLocalTime. For targets equipped with an MC146818A Real-Time Clock (which is the case for most PC-compatible systems), RTTarget-32's function RTCMOSSetSystemTime can be used for this purpose. At run time, the date and time is advanced automatically with time information supplied by GetTickCount. If an application calls Win32 API function SetTimeZoneInformation at startup, UTC (Coordinated Universal Time) system date and time is supported through functions GetSystemTime, SetSystemTime, and GetTimeZoneInformation. SetTimeZoneInformation also enables Daylight Saving Time (summer time). Examples:// Time zone data for US Eastern Standard Time (GMT + 5): TIME_ZONE_INFORMATION TZ_EST = { 5 * 60, // time zone bias (minutes) L"EST Standard Time", // Unicode name of time zone in winter {0,11,0,1,2}, // date when the above time starts 0, // bias for winter (minutes, usually 0) L"EST Daylight Saving", // Unicode name of time zone in summer {0,3,0,2,2}, // date when the above time starts -1 * 60}; // bias for summer (minutes, usually -60) // Time zone data for Central European Time (GMT - 1): TIME_ZONE_INFORMATION TZ_CET = { -1 * 60, // time zone bias (minutes) L"CET Standard Time", // Unicode name of time zone in winter {0,10,0,5,3}, // date when the above time starts 0, // bias for winter (minutes, usually 0) L"CET Summer Time", // Unicode name of time zone in summer {0,3,0,5,2}, // date when the above time starts -1 * 60}; // bias for summer (minutes, usually -60) SetTimeZoneInformation(&TZ_EST); // set US Eastern Standard Time SetTimeZoneInformation(&TZ_CET); // set Central European Time For more information about TIME_ZONE_INFORMATION, see the Win32 API documentation. SetTimeZoneInformation should be called at program startup before the current date/time is set. If it is never called, UTC system time and local time are identical and RTTarget-32 does not adjust its time for daylight saving/summer time. If function RTCMOSSetSystemTime is to be used and the currently set time zone information supports daylight saving (summer) time, then the CMOS real-time clock must be set to the local standard time and not daylight saving/summer time. Function RTCMOSSetRTC does this correctly. RTTarget-32 never reads or modifies the CMOS real-time clock automatically.
|