From b21dea2d72d90ef1875c18c8cd3b8fb48c2bd6d3 Mon Sep 17 00:00:00 2001 From: vrepetenko Date: Sun, 4 Sep 2022 07:11:14 +0000 Subject: [PATCH] Fixed RTC_PRER initialization git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15758 27425a3e-05d8-49a3-a47f-9c15f0e5edd8 --- os/hal/ports/STM32/LLD/SYSTICKv2/hal_st_lld.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/os/hal/ports/STM32/LLD/SYSTICKv2/hal_st_lld.c b/os/hal/ports/STM32/LLD/SYSTICKv2/hal_st_lld.c index 3d0cc0e80..778ecfd9b 100644 --- a/os/hal/ports/STM32/LLD/SYSTICKv2/hal_st_lld.c +++ b/os/hal/ports/STM32/LLD/SYSTICKv2/hal_st_lld.c @@ -109,7 +109,10 @@ void st_lld_init(void) { /* Activate free running Binary mode.*/ RTC->ICSR |= RTC_ICSR_BIN_0; - /* Set RTC prescaler.*/ + /* Set RTC prescaler. + Setting PRER has to be done as two writes. Write Sync part first + then Sync + Async. */ + RTC->PRER = STM32_ST_RTC_PRER_BITS & 0x7FFF; RTC->PRER = STM32_ST_RTC_PRER_BITS; /* Exit initialization mode.*/