I am having a strange issue with my custom radio protocol. I have ported the code to the 52840 and SDK15 from the nrf51822 where it is running with no issues.
The issue is that everything runs correctly when using the J-Link debugger. as soon as I disconnect the J-Link and perform a battery pull, the system will enter a boot loop. So far I have tracked it down (with LED blink signals, since it works again once I connect the debugger) to a point where the RADIO_IRQHandler is not being called after the battery pull.
The sequencs is like this (with SEGGER SES):
Debug->Run ---> works!
pull battery and re-insert ----> bootloop
Target->Reconnect J-Link ----> works fine after next boot!
Here is my Handler:
void RADIO_IRQHandler(void) {
LED_ON(LED_1); // LED never goes on that is how I know the IRQHandler is not called
uint8_t event = 0;
if (NRF_RADIO->EVENTS_READY) { // put each event separately in the scheduler, even if they occured simulatenously due to shorts
NRF_RADIO->EVENTS_READY = 0;
event = RADIO_EV_READY;
radio_handler(&event, sizeof(event));
}
#ifdef NRF52840_XXAA
if (NRF_RADIO->EVENTS_PHYEND) {
NRF_RADIO->EVENTS_PHYEND = 0;
event = RADIO_EV_PHYEND;
radio_handler(&event, sizeof(event));
}
#endif
if (NRF_RADIO->EVENTS_END) {
NRF_RADIO->EVENTS_END = 0;
event = RADIO_EV_END;
radio_handler(&event, sizeof(event));
}
if (NRF_RADIO->EVENTS_DISABLED) {
NRF_RADIO->EVENTS_DISABLED = 0;
event = RADIO_EV_DISABLED;
radio_handler(&event, sizeof(event));
}
}
and this is how I enable the interrupts:
radio_enable_irq() {
NRF_RADIO->INTENSET = RADIO_INTENSET_READY_Enabled << RADIO_INTENSET_READY_Pos |
RADIO_INTENSET_END_Enabled << RADIO_INTENSET_END_Pos |
RADIO_INTENSET_DISABLED_Enabled << RADIO_INTENSET_DISABLED_Pos |
#ifdef NRF52840_XXAA
RADIO_INTENSET_PHYEND_Enabled << RADIO_INTENSET_PHYEND_Pos |
#endif
0;
#ifdef NRF52840_XXAA
NRF_RADIO->EVENTS_PHYEND = 0;
#endif
NRF_RADIO->EVENTS_END = 0;
NRF_RADIO->EVENTS_DISABLED = 0;
NRF_RADIO->EVENTS_READY = 0;
NVIC_SetPriority(RADIO_IRQn, 1);
NVIC_ClearPendingIRQ(RADIO_IRQn);
NVIC_EnableIRQ(RADIO_IRQn);
}
Is there any known mechanism how the interrupts would become disabled after a battery pull? And what does the J-Link change that it works again?