Hello, I am trying to use the timer peripheral via registers only, however I am running into issues when I setup two timers and they activate at the same time. Here are my interrupt handlers:
void TIMER1_IRQHandler(void) { NRF_TIMER1->EVENTS_COMPARE[0] = 0; volatile uint32_t dummy = NRF_TIMER1->EVENTS_COMPARE[0]; (void)dummy; event_handler_bank[0][0].event_handler(); //calls test_handler() }
void TIMER2_IRQHandler(void) { NRF_TIMER2->EVENTS_COMPARE[0] = 0; volatile uint32_t dummy = NRF_TIMER2->EVENTS_COMPARE[0]; (void)dummy; event_handler_bank[1][0].event_handler(); //calls test_handler2() }
The end goal is to allow for custom event handlers for each channel compare event, It appears to be that when the timers 'intersect', timer1's routine is performed twice which might be proven via this scope probing on the onboard leds:
The yellow trace is the led toggled from IRQ1's interrupt while the blue trace is the led toggled from IRQ2's itnerrupt.
However the strangest thing is that the lights will perform perfectly if I flash it a random amount of times with the exact same source code! Here is a trace whenever the lights/timer work as intended:
It seems that whenever the IRQ2 is triggered first it works fine but when IRQ1 is triggered first it get triggered twice.
I am really confused on how to reliably create a different callbacks from multiple timer instances. I looked through your HAL code and saw this snippet (from nrfx_timer.c) :