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

RTC1 interrupt does't trigger, and what's event counter?

I'm try to use RTC1 to generate overflow interrupt, but it doesn't trigger interrupt.

void RTC1_IRQHandler(void)
{
  // do something
}

main()
{
  NRF_RTC1->TASKS_STOP = 1;
  NRF_RTC1->INTENSET = 0x2; // enable OVRFLW interrupt
//  NVIC_SetVector(RTC1_IRQn, (uint32_t) &RTC1_IRQHandler); // needed?
  NVIC_EnableIRQ(RTC1_IRQn );
  NRF_RTC1->TASKS_START = 1;
  while(1)
}

In my understanding, the vector for RTC1_IRQn() is already assigned in start-up code, so I skipped NVIC_SetVector(), however, the interrupt doesn't trigger even if setting NVIC_SetVector().

By watching the value of RTC1->COUNTER, it increments automatically, and OVRFLW event occurs by enabling overflow event by setting "NRF_RTC1->EVTENSET = 0x2;"

I also confusing the function of event counter. Does the event counter increments at every event? For example, in the following code, the event counter, NRF_RTC1->EVENTS_TICK, becomes 1 after the first tick, but it keeps 1. Doesn't event counter increase more than 1? (In other words, can I check it simply for checking event occurred or not?)

main()
{
  NRF_RTC1->TASKS_STOP = 1;
  NRF_RTC1->EVTENSET = 0x1; // enable Tick event
  NRF_RTC1->TASKS_START = 1;
  while(1)
}
Related