Skip to content

Commit

Permalink
hw/mcu/stm32: Disable SysTick when RTC is selected as tick source
Browse files Browse the repository at this point in the history
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.
Same code was already applied to STM32F1 that has different
RTC block.

Signed-off-by: Jerzy Kasenberg <[email protected]>
  • Loading branch information
kasjer committed Jul 10, 2024
1 parent 416ee1e commit 5a37e22
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions hw/mcu/stm/stm32_common/src/hal_os_tick.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,12 @@ os_tick_init(uint32_t os_ticks_per_sec, int prio)
.PeriphClockSelection = RCC_PERIPHCLK_RTC,
.RTCClockSelection = RCC_RTCCLKSOURCE_LSE,
};
/*
* Disable SysTick so only one interrupt advances time.
* this is needed when bootloader enabled SysTick
*/
SysTick->CTRL = 0;

HAL_RCCEx_PeriphCLKConfig(&clock_init);

/* Set the system tick priority. */
Expand Down

0 comments on commit 5a37e22

Please sign in to comment.