cancel
Showing results for 
Search instead for 
Did you mean: 

Bugs in LL_RTC_DATE_Init

Remi.G
Associate II

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

1 REPLY 1
Amel NASRI
ST Employee

Hi @Remi.G​ ,

Thanks for reporting this issue.

Comparing both implementations for STM32L4 and STM32H7, a fix is already deployed for stm32l4xx_ll_rtc.c: check implementation of IS_LL_RTC_MONTH.

I'll push to make this update on other packages like STM32H7 & STM32F7.

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.