How can I use IRQHandler in Zephyr?

Hello, I would like to use RTC2_IRQHandler in Zephyr environment.



However, each time an RTC interrupt is called, the entire system shuts down and reboots.



How can I use the RTC_IRQHandler?



Here's my source code.

main.cpp

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <zephyr/kernel.h>
#include <zephyr/irq.h>
#include <Configure.h>
#include <nRF52/RTC.h>
RTC CLOCK;
int main(void)
{
NRF_GPIO->DIRSET = (1 << GPIO_LED_RED) | (1 << GPIO_LED_GREEN) | (1 << GPIO_LED_BLUE);
CLOCK.Init(RTC2, 32);
CLOCK.setEvent(RTC2, RTC_INTERRUPT_COMPARE0);
CLOCK.setInterrupt(RTC2, RTC_INTERRUPT_COMPARE0);
CLOCK.Start(RTC2);
CLOCK.setCompare(RTC2, RTC_COMPARE0, 3000);
while(true){
NRF_GPIO->OUTCLR = (1 << GPIO_LED_RED) | (1 << GPIO_LED_GREEN) | (1 << GPIO_LED_BLUE);
NRF_GPIO->OUTSET = (1 << GPIO_LED_RED);
printk("CLOCK : %d\n", CLOCK.getCounter(RTC2));
k_msleep(1000);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

RTC.cpp

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "RTC.h"
void RTC::Init(uint8_t channel, uint16_t prescaler){
if(!(NRF_CLOCK->LFCLKSTAT >> 16) & 0x01){
NRF_CLOCK->LFCLKSRC = CLOCK_LFCLKSRC_SRC_Xtal;
NRF_CLOCK->TASKS_LFCLKSTART = 0x01;
while(!NRF_CLOCK->EVENTS_LFCLKSTARTED){}
}
switch(channel){
case RTC0:
NRF_RTC0->TASKS_CLEAR = 1;
NRF_RTC0->TASKS_STOP = 1;
NRF_RTC0->PRESCALER = 32;
printk("Settings : %d %d\n", NRF_RTC0->PRESCALER, prescaler);
break;
case RTC1:
NRF_RTC1->TASKS_CLEAR = 1;
NRF_RTC1->TASKS_STOP = 1;
NRF_RTC1->PRESCALER = prescaler;
break;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX