can i get utc time from rtc in samd20e

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hello all,

i am using samd20e, it has in built 32 bit rtc. for my application i need utc time.

i gone through the data sheet they did't mention about utc.

 

is it possible if not, any suggestions to get utc time.

Last Edited: Sat. Oct 1, 2016 - 07:47 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

manoharbompella wrote:
i gone through the data sheet

So you will have seen that RTC, in this context, is Real Time Counter

 

any suggestions to get utc time.

What, exactly, do you mean by "UTC time" here?

 

What about the Clock/Calendar mode of the RTC?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sorry awneil, for incomplete question.

utc time means i need time in secs only.

using rtc i am getting the time stamp in user readable format like yyyy/mm/dd::hh/mm/ss;

but i need only secs like 1475301477.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you set the time to UTC, the RTC should continue to return time still in UTC.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

manoharbompella wrote:

sorry awneil, for incomplete question.

utc time means i need time in secs only.

using rtc i am getting the time stamp in user readable format like yyyy/mm/dd::hh/mm/ss;

but i need only secs like 1475301477.

Remember that the RTC is reset at power on time, and counts seconds from enable time, so the calendar value is rather meaningless

Strictly speaking UTC corresponds with civil time, which can have leap seconds, as will happen at the end of this year.

It looks like you only need to count seconds from an arbitary point in time, so you have to set CTRL.MODE=00, as in the SAMD21 datasheet

If you want to convert the count to a meaningful date you have to know the count value corresponding to the time you set the counter. Perhaps you could use the UX system - there one counts seconds (but not leap seconds) since the start of 1970 Jan 1. See the standard header file time.h for function and variable definitions 

Jerry

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

manoharbompella wrote:
utc time means i need time in secs only.

Well, that's not what "UTC" actually means at all!

 

https://en.wikipedia.org/wiki/Co...

 

However, if what you need is just time in seconds, then why not just use the RTC in its 32-bit counter mode, and have it count in seconds?

 

Job done!

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

utc time means i need time in secs only.

 Ah.  I'm guessing what you really want is "unix time format" (epoch time) - total seconds since 1 January 1970 UTC, with a side issue of "can I use the RTC in clock/calendar mode, set the day/month/year/time, and read back the seconds-since-1970 value?"  The answer appears to be "no."

Your best bet is probably using the simpler "counter mode", along with the standard unix/C functions available to convert epoch to and from d/m/y formats...  (I believe you can SET the 32bit counter to an initial value, so if you set it at startup to the correct UTC epoch time, it should stay reasonably in sync thereafter...)

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As per my knowledge, RTC modules normally do not take in location details. Rather it simple runs the clock from the initial set value.

So, if you really need the RTC to work on UTC, then better set the time value to the current UTC value & thats it.

Then later on, when you need the time in your locality, you may read the RTC value & then make necessary addition to get the time in your locality.

smiley

Silly beans are always silly
:)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

westfw wrote:
Your best bet is probably using the simpler "counter mode", along with the standard unix/C functions available to convert epoch to and from d/m/y formats...

Agreed.

 

But does the microcontroller actually need d/m/y formats at all? What is the actual requirements in this particular application?

 

Similarly for timezones.

 

http://www.catb.org/esr/faqs/sma...

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...