Bugs in LL_RTC_DATE_Init
STM32Cube MCU package for STM32H7 v1.8.0
Also exists in F7 version, probably others.
To reproduce:
- enable RTC with LL code generation
- make sure assert_param() isn't stubbed out
- Set a date in October
- Try both BIN and BCD format, they both have slightly different issues
There are several bugs in LL_RTC_DATE_Init() when dealing with months >= October:
if ((RTC_Format == LL_RTC_FORMAT_BIN) && ((RTC_DateStruct->Month & 0x10U) == 0x10U))
{
RTC_DateStruct->Month = (uint8_t)((RTC_DateStruct->Month & (uint8_t)~(0x10U)) + 0x0AU);
}
- this is converting BCD to binary, so the RTC_Format check should be for BCD
assert_param(IS_LL_RTC_MONTH(RTC_DateStruct->Month));
assert_param(IS_LL_RTC_MONTH(__LL_RTC_CONVERT_BCD2BIN(RTC_DateStruct->Month)));
- the IS_LL_RTC_MONTH macro is comparing a binary value against a BCD LL_RTC_MONTH_x
