2020-01-02 03:56 AM
Hello, team!
In the stm32f4xx_hal_rtc.h header, the values for the months are set incorrectly
/* Coded in BCD format */
#define RTC_MONTH_JANUARY ((uint8_t)0x01)
#define RTC_MONTH_FEBRUARY ((uint8_t)0x02)
#define RTC_MONTH_MARCH ((uint8_t)0x03)
#define RTC_MONTH_APRIL ((uint8_t)0x04)
#define RTC_MONTH_MAY ((uint8_t)0x05)
#define RTC_MONTH_JUNE ((uint8_t)0x06)
#define RTC_MONTH_JULY ((uint8_t)0x07)
#define RTC_MONTH_AUGUST ((uint8_t)0x08)
#define RTC_MONTH_SEPTEMBER ((uint8_t)0x09)
#define RTC_MONTH_OCTOBER ((uint8_t)0x10) --> in decimal, this is 16
#define RTC_MONTH_NOVEMBER ((uint8_t)0x11) --> in decimal, this is 17
#define RTC_MONTH_DECEMBER ((uint8_t)0x12) --> in decimal, this is 18
The last three, shall be 0x0A, 0x0B, 0x0C in this order.
Can you please fix this?
2020-01-02 04:16 AM
2020-01-02 11:30 AM
Yes, this is exactly the same question.
2020-01-02 11:43 AM
/* Coded in BCD format */ not an error. The RTC has few transistors as it doesn't need to handle humans with their decimals.
2020-01-02 02:59 PM
Absolutely, I added that line for easier identification within the file.
2020-01-02 03:28 PM
Yes, so the hardware has BCD counters, per thread cited by Jan, the constants are provided to facilitate that.
If you want to pass binary values and have the RTC API code translated them, just use 1-12, and define a set of constants for that model if your code needs such, ST has the BCD ones because the number-space appears non-continuous and is liable to trap the unwary.