diff --git a/arch/xtensa/src/esp32s3/esp32s3_rt_timer.c b/arch/xtensa/src/esp32s3/esp32s3_rt_timer.c index 33c47926b0..46199135b0 100644 --- a/arch/xtensa/src/esp32s3/esp32s3_rt_timer.c +++ b/arch/xtensa/src/esp32s3/esp32s3_rt_timer.c @@ -572,10 +572,6 @@ static int rt_timer_thread(int argc, char *argv[]) kmm_free(timer); } - /* Enter critical section for next scanning list */ - - flags = spin_lock_irqsave(&priv->lock); - if (raw_state == RT_TIMER_TIMEOUT) { /* Check if the timer is in "repeat" mode */ @@ -585,6 +581,10 @@ static int rt_timer_thread(int argc, char *argv[]) start_rt_timer(timer, timer->timeout, true); } } + + /* Enter critical section for next scanning list */ + + flags = spin_lock_irqsave(&priv->lock); } spin_unlock_irqrestore(&priv->lock, flags);