Page 1 of 1

Safe to use "timer_ll_clear_intr_status" from non-ISR method?

Posted: Mon Dec 25, 2023 9:33 am
by pauldotknopf
Long story short, I'm monitoring a signal from a GPIO pin, and using it to keep a running timer (TIMER_GROUP_0, TIMER_0) in sync.

From my main loop, I'm using "portDISABLE_INTERRUPTS|portENABLE_INTERRUPTS" where I need to measure sensitive timings, and based on those results, I set new alarm/counter values.

However, I was having issues where a pending interrupt getting fired right when I re-enabled interrupts on my main loop. To solve this, I used the follow code (while interrupts were disabled).

auto dev = TIMER_LL_GET_HW(0);
timer_ll_clear_intr_status(dev, TIMER_0);
dev->hw_timer[TIMER_0].config.alarm_en = 1;

I know I shouldn't be touching the timer outside of it's public interface (which has spinlocks and safety checks). However, I don't think this would cause an issue, considering I have interrupts disabled entirely. Am I correct in this assumption?