From a6a6b21e4d2f289737d16d938632df7b73ed492e Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 24 Nov 2025 19:15:02 -0500 Subject: [PATCH] armcm_timer: Use a static instruction count for TIMER_MIN_TRY_TICKS Change TIMER_MIN_TRY_TICKS from 2us to 90 instructions. On newer chips 2us is a large amount of time - for example on the 520Mhz stm32h723 it would be 1040 instructions. Using a large time can result in "busy waiting" in the irq handler when the cpu may be better spent running tasks. The armcm_timer.c code is used on most ARM cortex-M chips and on all of these chips the SysTick timer should be tied directly to the instruction counter. This change should be safe because it should not take more than 90 instructions to reschedule the timer on any of these chips. Also, all of these chips should be able to exit the irq handler and reenter it in less than 90 instructions allowing more time for tasks to run if the next timer is more than 90 timer ticks in the future. Signed-off-by: Kevin O'Connor --- src/generic/armcm_timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/generic/armcm_timer.c b/src/generic/armcm_timer.c index b7f572685..e2d77924d 100644 --- a/src/generic/armcm_timer.c +++ b/src/generic/armcm_timer.c @@ -114,7 +114,7 @@ DECL_INIT(timer_init); static uint32_t timer_repeat_until; #define TIMER_REPEAT_TICKS timer_from_us(100) -#define TIMER_MIN_TRY_TICKS timer_from_us(2) +#define TIMER_MIN_TRY_TICKS 90 #define TIMER_DEFER_REPEAT_TICKS timer_from_us(5) // Invoke timers