You are here

Setup RTC time using unix timestamp | Cypress Semiconductor

Setup RTC time using unix timestamp

Summary: 1 Reply, Latest post by ran_d0m on 04 Oct 2016 08:42 AM PDT
Verified Answers: 1
Last post
Log in to post new comments.
user_459156114's picture
User
35 posts

I'm attempting to set the current time of my RTC by sending a Unix timestamp from a smartphone to the device. I am successfully able to get the timestamp from my smartphone to the ble device. 

If I try to just hardcode something to test like this: 

uint64_t out = 1475591308;
RTC_SetUnixTime(out);

My RTC clock goes to 1/11/2372 ??  Am I not implementing this right? The method signature in the RTC.h is: 

RTC_SetUnixTime(uint64 unixTime);

And the docs say: 

Sets the time in the Unix/Epoch time format - the number of seconds elapsed from January 1, 1970 UTC 00:00 hrs. 

===

Update: I've changed nothing and now when setting the unix time it freezes....story of my life. 

I'm trying to call RTC_SetUnixTime in my BleCallBack method if that helps at all. 

user_459156114's picture
User
35 posts

So I was able to fix this by adding in a couple of variables and updating the RTC from the main method instead of my BleCallBack method. So in my main now I have: 

if (!clockIsUpToDate) {
      RTC_SetUnixTime(newClockValue);
      clockIsUpToDate = 1;
}

I think my issue with this is not fully understanding the c run loop. 

Log in to post new comments.