RTC on STM32H7A3 / STM32H7B3 / STM32H7B0

Report here problems in any of ChibiOS components. This forum is NOT for support.
nikiwaibel
Posts: 29
Joined: Sat Mar 17, 2018 2:51 pm
Has thanked: 8 times
Been thanked: 15 times

RTC on STM32H7A3 / STM32H7B3 / STM32H7B0

Postby nikiwaibel » Thu Sep 26, 2024 10:32 am

hi,

in os/hal/ports/STM32/STM32H7xx/platform.mk, as well as os/hal/ports/STM32/STM32H7xx/platform_type2.mk, there is RTCv2 selected. the STM32H7A3, STM32H7B3 and STM32H7B0 (Q and no-Q variants) have something, that is much more similar to RTCv3, it seems.

should those variations of the STM32H7 use a possibly new os/hal/ports/STM32/STM32H7xx/platform_type3.mk?

at the moment (r16597), setting HAL_USE_RTC to TRUE fails for me. also with RTCv3, as some defines and a macro is/are missing:

Code: Select all

 Compiling hal_rtc_lld.c
os/hal/ports/STM32/LLD/RTCv3/hal_rtc_lld.c: In function 'rtc_lld_serve_interrupt':
os/hal/ports/STM32/LLD/RTCv3/hal_rtc_lld.c:273:3: error: implicit declaration of function 'STM32_RTC_CLEAR_ALL_EXTI'; did you mean 'STM32_RTC_ALARM_EXTI'? [-Wimplicit-function-declaration]
  273 |   STM32_RTC_CLEAR_ALL_EXTI();
      |   ^~~~~~~~~~~~~~~~~~~~~~~~
      |   STM32_RTC_ALARM_EXTI
os/hal/ports/STM32/LLD/RTCv3/hal_rtc_lld.c: In function 'rtc_lld_init':
os/hal/ports/STM32/LLD/RTCv3/hal_rtc_lld.c:437:44: error: 'STM32_RTC_CR_MASK' undeclared (first use in this function); did you mean 'STM32_RTCSEL_MASK'?
  437 |     RTCD1.rtc->CR   = (STM32_RTC_CR_INIT & STM32_RTC_CR_MASK) | RTC_CR_BYPSHAD;
      |                                            ^~~~~~~~~~~~~~~~~
      |                                            STM32_RTCSEL_MASK
os/hal/ports/STM32/LLD/RTCv3/hal_rtc_lld.c:437:44: note: each undeclared identifier is reported only once for each function it appears in
os/hal/ports/STM32/LLD/RTCv3/hal_rtc_lld.c:450:47: error: 'STM32_TAMP_CR1_MASK' undeclared (first use in this function); did you mean 'STM32_TAMP_CR1_INIT'?
  450 |   RTCD1.tamp->CR1   |= (STM32_TAMP_CR1_INIT & STM32_TAMP_CR1_MASK);
      |                                               ^~~~~~~~~~~~~~~~~~~
      |                                               STM32_TAMP_CR1_INIT
os/hal/ports/STM32/LLD/RTCv3/hal_rtc_lld.c:451:47: error: 'STM32_TAMP_CR2_MASK' undeclared (first use in this function); did you mean 'STM32_TIM_CR2_MMS2'?
  451 |   RTCD1.tamp->CR2   |= (STM32_TAMP_CR2_INIT & STM32_TAMP_CR2_MASK);
      |                                               ^~~~~~~~~~~~~~~~~~~
      |                                               STM32_TIM_CR2_MMS2
os/hal/ports/STM32/LLD/RTCv3/hal_rtc_lld.c:452:49: error: 'STM32_TAMP_FLTCR_MASK' undeclared (first use in this function); did you mean 'STM32_TAMP_FLTCR_INIT'?
  452 |   RTCD1.tamp->FLTCR |= (STM32_TAMP_FLTCR_INIT & STM32_TAMP_FLTCR_MASK);
      |                                                 ^~~~~~~~~~~~~~~~~~~~~
      |                                                 STM32_TAMP_FLTCR_INIT
os/hal/ports/STM32/LLD/RTCv3/hal_rtc_lld.c:453:47: error: 'STM32_TAMP_IER_MASK' undeclared (first use in this function); did you mean 'STM32_MDMA_ISR_MASK'?
  453 |   RTCD1.tamp->IER   |= (STM32_TAMP_IER_INIT & STM32_TAMP_IER_MASK);
      |                                               ^~~~~~~~~~~~~~~~~~~
      |                                               STM32_MDMA_ISR_MASK
os/hal/ports/STM32/LLD/RTCv3/hal_rtc_lld.c:459:3: error: implicit declaration of function 'STM32_RTC_ENABLE_ALL_EXTI'; did you mean 'STM32_RTC_ALARM_EXTI'? [-Wimplicit-function-declaration]
  459 |   STM32_RTC_ENABLE_ALL_EXTI();
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~
      |   STM32_RTC_ALARM_EXTI
make[1]: *** [os/common/startup/ARMCMx/compilers/GCC/mk/rules.mk:194: builds/STM32H7A3II/obj/hal_rtc_lld.o] Error 1
make[1]: Leaving directory 'src'
make: *** [Makefile:225: builds/STM32H7A3II/STM32H7A3II.elf] Error 2


further, some code in os/hal/ports/STM32/STM32H7xx/hal_lld.c in function init_bkp_domain() may need to be adjusted, as it resets the backup domain (which includes the wiping RTC backup registers), when HAL_USE_RTC is set to FALSE. maybe wrapping

Code: Select all

#if HAL_USE_RTC
#endif /* HAL_USE_RTC */

around

Code: Select all

  /* Reset BKP domain if different clock source selected.*/
  if ((RCC->BDCR & STM32_RTCSEL_MASK) != STM32_RTCSEL) {
    /* Backup domain reset.*/
    RCC->BDCR = RCC_BDCR_BDRST;
    RCC->BDCR = 0;
  }

is sufficient …

User avatar
Giovanni
Site Admin
Posts: 14563
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1111 times
Been thanked: 937 times
Contact:

Re: RTC on STM32H7A3 / STM32H7B3 / STM32H7B0

Postby Giovanni » Thu Sep 26, 2024 5:47 pm

Hi,

Moving this in "bug reports".

Giovanni

nikiwaibel
Posts: 29
Joined: Sat Mar 17, 2018 2:51 pm
Has thanked: 8 times
Been thanked: 15 times

Re: RTC on STM32H7A3 / STM32H7B3 / STM32H7B0

Postby nikiwaibel » Fri Sep 27, 2024 1:19 pm

this may be related to viewtopic.php?f=35&t=6352


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 7 guests