RTC interrupt handler not working.

static void RTC1_IRQHandler(void){
  
  NRF_RTC1->TASKS_CLEAR = 1;
  SEGGER_RTT_printf(0,"INTERRUPT TRIGGERED.\n");
  if(NRF_RTC1->EVENTS_COMPARE[0]){
    NRF_RTC1->EVENTS_COMPARE[0] = 0;
    }
}

static void RTC1_INIT(uint32_t time_ticks){

  NRF_RTC1->PRESCALER = 4095;      //prescaler = 4096
  NRF_RTC1->EVTEN = (1<<16);
  NRF_RTC1->EVTENSET = (1 << 16);   //enable event routing for COMPARE[0] event
  NRF_RTC1->INTENSET = (1 << 16);   //enable interrupt for compare[0] event
  NRF_RTC1->CC[0] = time_ticks;

  NVIC_SetPriority(RTC1_IRQn, 7);
  NVIC_EnableIRQ(RTC1_IRQn);

  NRF_RTC1->TASKS_START = 1;
  SEGGER_RTT_printf(0,"RTC STARTED.\n");
}

I am trying to initialize the RTC and trigger an interrupt every 10 seconds, and I am unsure of why the code above is not working. I followed a similar method to initialize Timer1 along with an interrupt function, and that works fine. As an additional question, is the difference in power savings between RTC and TIMER (using PCLK1M) significant?

Thanks for the help.

Related