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
RTC valid year values?
Moderator: RoccoMarco
- Giovanni
- Site Admin
- Posts: 14893
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: RTC valid year values?
The STM32 supports two digits for years, so it is a 100 years span.
Giovanni
Giovanni
-
mikemoretti
- Posts: 12
- Joined: Sun Nov 29, 2015 9:37 pm
Re: RTC valid year values?
So, that means 1980 - 2079?
What I'm trying to also figure out is where the "1980" came from?
Thanks,
-m
What I'm trying to also figure out is where the "1980" came from?
Thanks,
-m
- Giovanni
- Site Admin
- Posts: 14893
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
-
mikemoretti
- Posts: 12
- Joined: Sun Nov 29, 2015 9:37 pm
Re: RTC valid year values?
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
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
- Giovanni
- Site Admin
- Posts: 14893
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: RTC valid year values?
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
Giovanni
-
mikemoretti
- Posts: 12
- Joined: Sun Nov 29, 2015 9:37 pm
Re: RTC valid year values?
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.