Skip to main content
Visitor II
February 18, 2021
Question

Bugs in LL_RTC_DATE_Init

  • February 18, 2021
  • 1 reply
  • 680 views

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

    This topic has been closed for replies.

    1 reply

    Technical Moderator
    February 23, 2021

    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