From 6d2f840ccd2981e18088a588baf23af160ac757b Mon Sep 17 00:00:00 2001 From: Jerzy Kasenberg Date: Wed, 12 Jun 2024 12:37:27 +0200 Subject: [PATCH] hw/mcu/stm32f1: Disable SysTick when RTC is selected as tick source When tick was provided by RTC instead of SysTick (default) and MCUboot used SysTick during boot, SysTick was never turned off and was running in application code. This resulted in two interrupts advancing mynewt OS tick so clock was running too fast. Now os_tick_init() from RTC code disables SysTick that could be started in bootloader Signed-off-by: Jerzy Kasenberg --- hw/mcu/stm/stm32f1xx/src/rtc_tick_stm32f1xx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/mcu/stm/stm32f1xx/src/rtc_tick_stm32f1xx.c b/hw/mcu/stm/stm32f1xx/src/rtc_tick_stm32f1xx.c index 3220991f32..9f27be4f17 100644 --- a/hw/mcu/stm/stm32f1xx/src/rtc_tick_stm32f1xx.c +++ b/hw/mcu/stm/stm32f1xx/src/rtc_tick_stm32f1xx.c @@ -120,6 +120,7 @@ os_tick_init(uint32_t os_ticks_per_sec, int prio) .PeriphClockSelection = RCC_PERIPHCLK_RTC, .RTCClockSelection = RCC_RTCCLKSOURCE_LSE, }; + SysTick->CTRL = 0; HAL_RCCEx_PeriphCLKConfig(&clock_init); __HAL_RCC_RTC_ENABLE();