Skip to content

Commit 87dbd2e

Browse files
jurenatkartben
authored andcommitted
drivers: counter: stm32: Disable BYPSHAD in init
Disable the shadow registers bypass in init function before RTC deinitialisation to avoid infinite loop as the bit cases the RSF bit to be kept in 0. The systick is not working in PRE_KERNEL_1 so it will never timeout. Signed-off-by: Tomáš Juřena <[email protected]>
1 parent c1bbed6 commit 87dbd2e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/counter/counter_ll_stm32_rtc.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,18 @@ static int rtc_stm32_init(const struct device *dev)
590590
z_stm32_hsem_unlock(CFG_HW_RCC_SEMID);
591591

592592
#if !defined(CONFIG_COUNTER_RTC_STM32_SAVE_VALUE_BETWEEN_RESETS)
593+
594+
/* STM32C0 LL driver does not clear the CR register in LL_RTC_DeInit so it will loop forever waiting
595+
* for a flag that will never be set when shadow registers are bypassed (BYPSHAD enabled).
596+
*/
597+
#if defined(RTC_CR_BYPSHAD) && defined(CONFIG_SOC_SERIES_STM32C0X)
598+
if (LL_RTC_IsShadowRegBypassEnabled(RTC)) {
599+
LL_RTC_DisableWriteProtection(RTC);
600+
LL_RTC_DisableShadowRegBypass(RTC);
601+
LL_RTC_EnableWriteProtection(RTC);
602+
}
603+
#endif /* defined(RTC_CR_BYPSHAD) && defined(CONFIG_SOC_SERIES_STM32C0X) */
604+
593605
if (LL_RTC_DeInit(RTC) != SUCCESS) {
594606
goto out_disable_bkup_access;
595607
}

0 commit comments

Comments
 (0)