This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Is there any way to force a COMPARE interrupt on TIMER0 for nrf52?

Hello,

I am using the nrf52pdk and am wondering if there is a way to force an output compare interrupt to occur. For example, lets say you want to generate an interrupt when the timer counter value reaches a particular value. To do this, you have to set up the EVENTS_COMPARE (which I know how to do) and you also need to write to the timer CC register (one of them at least). For example: NRF_TIMER0->CC[0] = compare_value. Note I am using TIMER0 in my app.

What happens if you set the output compare but the timer counter just passed it? For example, the compare value you want to write is 2330 but the counter is 2331. In this case, you wont get an interrupt until the timer counter wraps back around.

What I wanted to do in this case is to just simply force the interrupt to occur. However, I don't see a way to do this. Lots of other MCU's have this capability but it appears that the nrf52 does not.

Does anyone know of a way to do this?

Another related question (sort of): if you write the CC register to the same value as the timer counter (ie. the timer counter is currently at 700 and you write 700 to the compare register) do you get an output compare event? It does not appear to be the case but I could have something wrong in my test code...

Thanks, Will

Related