RTC driver for Kinetis.

ChibiOS public support forum for topics related to the Freescale Kinetis family of micro-controllers.

Moderator: utzig

User avatar
Giovanni
Site Admin
Posts: 11081
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 367 times
Been thanked: 306 times
Contact:

Re: RTC driver for Kinetis.

Postby Giovanni » Wed Sep 10, 2014 2:45 pm

Only 1) is an error.

Most RTCs have calendar-like registers like the mentioned RTCv2, Kinetis appears to be the exception with its 32 bits counter, the same solution of STM32F1 devices incidentally. This is why RTCv1 is not done yet, probably the code could be shared.

1980 is just a convenient year.

Giovanni

SpaceCoaster
Posts: 49
Joined: Mon Aug 11, 2014 6:40 am

Re: RTC driver for Kinetis.

Postby SpaceCoaster » Wed Sep 10, 2014 5:38 pm

Giovanni,

I added conversions between RTCDateTime and time_t to the Kinetis rtc_lld.c based on the toolchain provided mktime() and localtime_r() functions.

Code: Select all

void RTCDateTime2TimeT(time_t *tt, const RTCDateTime *dtp);
void TimeT2RTCDateTime(const time_t *tt, RTCDateTime *dtp);

The downside is that it adds 3.5K to the program size due to the library sizes. The code could definitely be renamed and shared.

1980 is the year that DOS uses as the epoch.

Derek

colin
Posts: 149
Joined: Thu Dec 22, 2011 7:44 pm

Re: RTC driver for Kinetis.

Postby colin » Wed Sep 10, 2014 5:56 pm

SpaceCoaster wrote:Hmmm, DST changes at between 2AM and 3AM in the US. Some nights have 2 x 2:30AM, some nights have none. Alarms which span DST changes would be tricky.


Absolutely that is a huge concern. DST makes things ugly. I have always wondered if the DST time change "repeated hour" or 2AM-3AM could play a part in some 2:30AM murder case where the suspect's alibi places him 50 miles from the crime scene at 2:30AM. But which 2:30AM is it?! There is not even a way to represent that!

UTC for the win.

fpga_comp
Posts: 16
Joined: Thu Aug 28, 2014 2:00 pm

Re: RTC driver for Kinetis.

Postby fpga_comp » Thu Sep 11, 2014 1:28 am

Not all ports are going to have RTC. You can only rely on binary counters on Kinetic K2X or low end micros e.g. AVR.
So either you are going to need to emulate the RTC in software via 1 second interrupts or simply use binary counters for time stamps.


Return to “Kinetis Support”

Who is online

Users browsing this forum: No registered users and 1 guest