cancel
Showing results for 
Search instead for 
Did you mean: 

WICED Smart Bluetooth

Anonymous
Not applicable

I'm using BCM20737S.

The followings are output of rtc_ctime() and rtc_RtcTime2Sec().

If RtcTime.year is 2016, it seems that rtc_RtcTime2Sec() ignores RtcTime.month.

Jan 1 12:00:00 2015 / seconds: 157809600
Feb 1 12:00:00 2015 / seconds: 160488000
Mar 1 12:00:00 2015 / seconds: 162907200
Apr 1 12:00:00 2015 / seconds: 165585600
May 1 12:00:00 2015 / seconds: 168177600
Jun 1 12:00:00 2015 / seconds: 170856000
Jul 1 12:00:00 2015 / seconds: 173448000
Aug 1 12:00:00 2015 / seconds: 176126400
Sep 1 12:00:00 2015 / seconds: 178804800
Oct 1 12:00:00 2015 / seconds: 181396800
Nov 1 12:00:00 2015 / seconds: 184075200
Dec 1 12:00:00 2015 / seconds: 186667200

Jan 1 12:00:00 2016 / seconds: 189345600
Feb 1 12:00:00 2016 / seconds: 189345600
Mar 1 12:00:00 2016 / seconds: 189345600
Apr 1 12:00:00 2016 / seconds: 189345600
May 1 12:00:00 2016 / seconds: 189345600
Jun 1 12:00:00 2016 / seconds: 189345600
Jul 1 12:00:00 2016 / seconds: 189345600
Aug 1 12:00:00 2016 / seconds: 189345600
Sep 1 12:00:00 2016 / seconds: 189345600
Oct 1 12:00:00 2016 / seconds: 189345600
Nov 1 12:00:00 2016 / seconds: 189345600
Dec 1 12:00:00 2016 / seconds: 189345600

Jan 15 12:00:00 2016 / seconds: 190555200
Feb 15 12:00:00 2016 / seconds: 190555200
Mar 15 12:00:00 2016 / seconds: 190555200
Apr 15 12:00:00 2016 / seconds: 190555200
May 15 12:00:00 2016 / seconds: 190555200
Jun 15 12:00:00 2016 / seconds: 190555200
Jul 15 12:00:00 2016 / seconds: 190555200
Aug 15 12:00:00 2016 / seconds: 190555200
Sep 15 12:00:00 2016 / seconds: 190555200
Oct 15 12:00:00 2016 / seconds: 190555200
Nov 15 12:00:00 2016 / seconds: 190555200
Dec 15 12:00:00 2016 / seconds: 190555200

Jan 28 12:00:00 2016 / seconds: 191678400
Feb 28 12:00:00 2016 / seconds: 191678400
Mar 28 12:00:00 2016 / seconds: 191678400
Apr 28 12:00:00 2016 / seconds: 191678400
May 28 12:00:00 2016 / seconds: 191678400
Jun 28 12:00:00 2016 / seconds: 191678400
Jul 28 12:00:00 2016 / seconds: 191678400
Aug 28 12:00:00 2016 / seconds: 191678400
Sep 28 12:00:00 2016 / seconds: 191678400
Oct 28 12:00:00 2016 / seconds: 191678400
Nov 28 12:00:00 2016 / seconds: 191678400
Dec 28 12:00:00 2016 / seconds: 191678400

Jan 1 12:00:00 2017 / seconds: 220968000
Feb 1 12:00:00 2017 / seconds: 223646400
Mar 1 12:00:00 2017 / seconds: 226065600
Apr 1 12:00:00 2017 / seconds: 228744000
May 1 12:00:00 2017 / seconds: 231336000
Jun 1 12:00:00 2017 / seconds: 234014400
Jul 1 12:00:00 2017 / seconds: 236606400
Aug 1 12:00:00 2017 / seconds: 239284800
Sep 1 12:00:00 2017 / seconds: 241963200
Oct 1 12:00:00 2017 / seconds: 244555200
Nov 1 12:00:00 2017 / seconds: 247233600
Dec 1 12:00:00 2017 / seconds: 249825600

Jan 1 12:00:00 2018 / seconds: 252504000
Feb 1 12:00:00 2018 / seconds: 255182400
Mar 1 12:00:00 2018 / seconds: 257601600
Apr 1 12:00:00 2018 / seconds: 260280000
May 1 12:00:00 2018 / seconds: 262872000
Jun 1 12:00:00 2018 / seconds: 265550400
Jul 1 12:00:00 2018 / seconds: 268142400
Aug 1 12:00:00 2018 / seconds: 270820800
Sep 1 12:00:00 2018 / seconds: 273499200
Oct 1 12:00:00 2018 / seconds: 276091200
Nov 1 12:00:00 2018 / seconds: 278769600
Dec 1 12:00:00 2018 / seconds: 281361600

0 Likes
Reply
1 Solution
Anonymous
Not applicable

Sorry for the delayed response, we were working on getting the fix for you.

Please see the code below for the RtcTime2Sec workaround.

#include "rtc.h"

/////////////////////////////////////////////////////////////////////
/// Conver from RTC_time format to UINT32 seconds format
///  
/// \param rtctime - timer object pointer to be converted 
/// \param second  - converted UINT32 seconds
/////////////////////////////////////////////////////////////////////
void _rtc_RtcTime2Sec(RtcTime *rtctime, UINT32 *second)
{
   UINT32      days;
   int         i;
   UINT8      months[12] ={31,28,31,30,31,30,31,31,30,31,30,31};
   //int         daysPerYear;

   i = BASE_LINE_REF_YEAR;
   days  =  0;

   while ( i < rtctime->year )
   {
       days += 365;

       if ( ( (i % 400) == 0 ) || ( ( (i % 4) == 0) && ( (i % 100) != 0 ) )  )
       {
           days ++;    // leap year
       }

       i ++;
   }

   // leap year
   if ( ( (rtctime->year % 400) == 0 ) || ( ( (rtctime->year % 4) == 0 ) && ( (rtctime->year % 100) != 0 ) )  )
   {
       months[1] = 29;
   }


   i=0;
   while ( i < rtctime->month )
   {
       days += months;

       i++;
   }

   days += (rtctime->day-1);      //notes : day from app/user is 1 base

   *second = days * (24*60*60) + rtctime->hour * (60*60) + rtctime->minute *60 + rtctime->second;
}

Thanks,

Kevin

View solution in original post

0 Likes
Reply
10 Replies
Moderator
Moderator

brownie

There is an excellent example here of how to setup and use the internal RTC: Source Code: deep sleep enablement and the associated clock source handling...

This application essentially provides the sample code for setting up and interfacing with the on-chip RTC clock. The context is based on using the RTC with an external LPO (32KHz xtal) for timed wake from deep sleep, but it should also provide pretty solid direction with regards to using the RTC as well. If you are still having issues, then we will need to run this one past the developers.

I'm suprised that this is the first time someone has asked about this functionality (another question was posted here How to get System Time ? on the same subject).

yaocing_shih  dmiya kwang

0 Likes
Reply
Anonymous
Not applicable

I referenced a similar example in WICED Smart SDK.

Please ask development team that try to modify current_time.year to 2016 and check output of rtc_RtcTime2Sec().

0 Likes
Reply
Anonymous
Not applicable

mwf_mmfae,

As brownie reported, rtc_RtcTime2Sec seems to have an issue about leap year.

Please reproduce it with attached sample.

0 Likes
Reply
Moderator
Moderator

We'll have the developers take a look at this issue next week.

kwang

0 Likes
Reply
Anonymous
Not applicable

mwf_mmfae:

Do you have any updates?

If it is possible, I hope to use fixed source code of rtc_RtcTime2Sec().


0 Likes
Reply
Moderator
Moderator

I'm out this week but will ask the team if they were able to address in the meeting.

kwang j.t arvinds

0 Likes
Reply
Anonymous
Not applicable

Sorry for the delayed response, we were working on getting the fix for you.

Please see the code below for the RtcTime2Sec workaround.

#include "rtc.h"

/////////////////////////////////////////////////////////////////////
/// Conver from RTC_time format to UINT32 seconds format
///  
/// \param rtctime - timer object pointer to be converted 
/// \param second  - converted UINT32 seconds
/////////////////////////////////////////////////////////////////////
void _rtc_RtcTime2Sec(RtcTime *rtctime, UINT32 *second)
{
   UINT32      days;
   int         i;
   UINT8      months[12] ={31,28,31,30,31,30,31,31,30,31,30,31};
   //int         daysPerYear;

   i = BASE_LINE_REF_YEAR;
   days  =  0;

   while ( i < rtctime->year )
   {
       days += 365;

       if ( ( (i % 400) == 0 ) || ( ( (i % 4) == 0) && ( (i % 100) != 0 ) )  )
       {
           days ++;    // leap year
       }

       i ++;
   }

   // leap year
   if ( ( (rtctime->year % 400) == 0 ) || ( ( (rtctime->year % 4) == 0 ) && ( (rtctime->year % 100) != 0 ) )  )
   {
       months[1] = 29;
   }


   i=0;
   while ( i < rtctime->month )
   {
       days += months;

       i++;
   }

   days += (rtctime->day-1);      //notes : day from app/user is 1 base

   *second = days * (24*60*60) + rtctime->hour * (60*60) + rtctime->minute *60 + rtctime->second;
}

Thanks,

Kevin

View solution in original post

0 Likes
Reply
Anonymous
Not applicable

Thanks kwnag!

Do you plan to include this fix for next release of WICED Smart SDK?


0 Likes
Reply
Anonymous
Not applicable

hi brownieI believe it will be fixed with the next SDK, however we do not currently have an ETA on the next SDK release.

mwf_mmfae please correct me if I'm wrong

0 Likes
Reply
Moderator
Moderator

We do not have an ETA for the next release of the WICED Smart SDK.

0 Likes
Reply