Page 1 of 1
RTC valid year values?
Posted: Fri Dec 04, 2015 3:15 pm
by mikemoretti
Hi,
What is the valid range of values for the "year" field for the RTC date time structure? I couldn't find anything in any of the STM32 docs that say what values are valid for the year bcd registers, and the Chibios api docs say the year base is 1980 for the chibios RTC date time structure but don't really say much else about it...
Thanks!
-m
Re: RTC valid year values?
Posted: Fri Dec 04, 2015 3:26 pm
by Giovanni
The STM32 supports two digits for years, so it is a 100 years span.
Giovanni
Re: RTC valid year values?
Posted: Fri Dec 04, 2015 3:29 pm
by mikemoretti
So, that means 1980 - 2079?
What I'm trying to also figure out is where the "1980" came from?
Thanks,
-m
Re: RTC valid year values?
Posted: Fri Dec 04, 2015 3:41 pm
by Giovanni
It is completely arbitrary.
Giovanni
Re: RTC valid year values?
Posted: Fri Dec 04, 2015 3:51 pm
by mikemoretti
So I'm confused. Is the 1980 a Chibios arbitrary choice or is it an STM32 arbitrary choice?
The STM32 is supposed to take into account leap years and such. So is Chibios mapping properly to STM32 expected values? Leap year is a really wacky formula based on 4 and 100 and 200 years and such (i.e. every 4 years except for years divisible by 100 but yes for years divisible by 400). And if the years don't match right the leap year is calculated wrong.
Thanks,
-m
Re: RTC valid year values?
Posted: Fri Dec 04, 2015 5:24 pm
by Giovanni
1980 is chosen to be a leap year, I doubt that the STM32 RTC will skip century years, it only handles 2 digits. Details are in the STM32 reference manuals, the driver does just convert formats without providing any intelligence.
Giovanni
Re: RTC valid year values?
Posted: Fri Dec 04, 2015 5:45 pm
by mikemoretti
Thanks! I looked in the f4 ref man and didn't see anything about it. I just now realize that my worry was totally unfounded anyway because 2000 was a leap year so no matter how the mapping is done it doesn't matter.