This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

endian problem

hi,

we have endian problem in settime . we are using 32 bit MCU,

we have set time but device time changes to a completely different value 

There shouldnt be endian problem in driver right?

I saw in web page

System Up Time:
0 days 00:01:35
Time and Date:
16.08.1951 17:33:03

But when I run same code on PC time is OK

Could you please help...

Regards,

static _i32 setTime()
{
SlDateTime_t dateTime= {0};
_i32 retVal = 0;

memset ((_u8 *)(&dateTime),0,sizeof(SlDateTime_t));

dateTime.sl_tm_sec = 00;
dateTime.sl_tm_min = 45;
dateTime.sl_tm_hour = 11;

dateTime.sl_tm_day = 27;
dateTime.sl_tm_mon = 2;
dateTime.sl_tm_year = 2015;

dateTime.sl_tm_week_day=0;
dateTime.sl_tm_year_day=0;

retVal = sl_DevSet(SL_DEVICE_GENERAL_CONFIGURATION,
SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME,
sizeof(SlDateTime_t),(_u8 *)(&dateTime));
ASSERT_ON_ERROR(retVal);

return SUCCESS;
}

  • I have an example that sets time and works fine, you can see the code here - github.com/.../startproject_cc3200_ti-rtos

    Look for setDeviceTimeDate() in the startproject.c file, which then references the simplelinklibrary.c functions.

    Glenn.
  • I'm afraid
    it doest work,
    still same.
  • Hi,
    after bit shift it worked,

    System Up Time:
    0 days 00:00:36
    Time and Date:
    27.02.2015 11:45:38


    But why did I need to convert?
    there may be lots of things working with _u32 in driver
    Do we need to change all driver code?

    Working code below

    static _i32 setTime()
    {
    SlDateTime_t dateTime= {0};
    _i32 retVal = 0;



    dateTime.sl_tm_sec = 00;
    dateTime.sl_tm_min = 45<<24;
    dateTime.sl_tm_hour = 11<<24;

    dateTime.sl_tm_day = 27<<24;
    dateTime.sl_tm_mon = 2<<24;
    dateTime.sl_tm_year = 0xDF07<<16; //2015 in hexform 07DF




    unsigned char configLen = (unsigned char)sizeof(SlDateTime_t);
    unsigned char configOpt = (unsigned char)SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME;
    retVal = sl_DevSet(SL_DEVICE_GENERAL_CONFIGURATION,
    configOpt,
    configLen,(_u8 *)(&dateTime));
    ASSERT_ON_ERROR(retVal);

    return SUCCESS;
    }
  • Are you saying that my code did not work on your board?

    Try downloading the entire project and run it and see whether you get any issues.

    Glenn.
  • Dear Glenn,

    I cannot take entire project, my board is completely different.

    First I directly used example codes provided in SDK

    Also ı tried yours only for settime,

    the only difference wa (_u32) casting. below part

    I can only get it work by shifting, endian conversion...

    regards,

     

     

     dateTime.sl_tm_day =   (_u32)21;          // Day of month (DD format) range 1-31
        dateTime.sl_tm_mon =   (_u32)12;          // Month (MM format) in the range of 1-12
        dateTime.sl_tm_year =  (_u32)2014;        // Year (YYYY format)
        dateTime.sl_tm_hour =  (_u32)20;          // Hours in the range of 0-23
        dateTime.sl_tm_min =   (_u32)30;          // Minutes in the range of 0-59
        dateTime.sl_tm_sec =   (_u32)15;          // Seconds in the range of  0-59

        iretVal = setDeviceTimeDate();
        if (iretVal < 0)
        {
         System_printf("Failed to set Device Time and Date\n");
         System_flush();
        }

     

     

     

  • Rifat said:
    I cannot take entire project, my board is completely different.

    Perhaps this is the factor that is causing the issue.

    Can you explain what your board is?

    Glenn.

  • Hi Rifat,

    Did your queries got answered. If yes please press the "Verify Answer" button to close this thread.

    Thanks and Regards,
    Siddaram
  • Hi Rifat,

    I am closing this thread, if the issue still exists please open a new thread and add a link to this one for reference

    Thanks and Regards,
    Siddaram