none
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(!pcf8563_get_datetime(&lpst)) 

        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 ? 

    Thanks 
    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.

    http://msdn.microsoft.com/en-us/library/aa447109.aspx

    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.
    Vinoth.R

    http://vinoth-vinothblog.blogspot.com
    http://www.e-consystems.com/windowsce.asp

    Thursday, December 18, 2014 10:36 AM