Windows CE 7 and RTC RRS feed

  • Question

  • Hi to all, 

    I'm writing a RTC driver for Windows CE 7, and this is my first experience with Windows CE driver.... 

    At the boot I read from external RTC IC the date/time via I2C and then I try to set the system time via SetLocalTime function. 


        if(!SetLocalTime((const SYSTEMTIME *)&lpst)) 
            DEBUGMSG(ZONE_ERROR, (TEXT("FAiled to set System Time\r\n"))); 

    but the SetLocalTime fails... 

    Why ? 

    I read the for do this I need the  SE_SYSTEMTIME_NAME privilege but How I can set this privilege ? 

    Thursday, December 18, 2014 8:32 AM

All replies

  • Does your processor has internal RTC and are you trying to set the internal RTC from your external RTC ?

    Normally RTC code is implemented in OAL part of your BSP, you have to implement a set of function as shown in the bellow MSDN link.


    you have to implement the  OEMSetRealtime,OEMGetRealTime and IOCTL_HAL_INIT_RTC kernel IO Control. while booting IOCTL_HAL_INIT_RTC  will be called by kernel, here you have to retrieve the time from the external RTC and set it your Internal RTC as well as send the time back to kernel through the same system time pointer. 

    if the retrieve RTC time is invalid, you have to set the given time from the IOCTL to the external RTC and later we can set the correct time through the SetSystemTime from your APP/Shell.

    when you call setsystemtime(), OEMSetRealtime will be called and when you call GetsystemTime() from you app, OEMGetRealTime() will be called. you can use the Internal RTC for OEMSetRealTime and OEMGetRealtime implementation to avoid the I2C overhead to access external RTC everytime.

    Simple way to sync the internal RTC and external RTC,

    when ever you change the system time, there are some notification option for this and you can run an application to access the external RTC through I2C driver to sync with internal RTC.

    See the API: CeRunAppAtEvent and Event: NOTIFICATION_EVENT_TIME_CHANGE

    Please mark as answer, if it is correct.
    Please vote,if it is helpful post.


    Thursday, December 18, 2014 10:36 AM