cancel
Showing results for 
Search instead for 
Did you mean: 

Value definitions in generated file stm32f4xx_hal_rtc.h are incorrect

Omcsesz
Associate II

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?

5 REPLIES 5

Yes, this is exactly the same question.

/* Coded in BCD format */ not an error. The RTC has few transistors as it doesn't need to handle humans with their decimals.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Absolutely, I added that line for easier identification within the file.

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..