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

How can I get interrupts from the RADIO?

Hello,

I'm using nRF51822 to implement a proprietary radio protocol. My first attempt, in the receiver, was polling the EVENTS_* registers. An example:


NRF_RADIO->EVENTS_READY = 0UL;
NRF_RADIO->TASKS_RXEN = 1UL;
while (NRF_RADIO->EVENTS_READY == 0UL);

But I need to do other things while the RADIO is transmitting or receiving. I tried to use RADIO_IRQn with no success:


void RADIO_IRQHandler(void)
{
	log_uart("IRQ!!!\r\n");
}

void init(void)
{
	NVIC_SetPriority(RADIO_IRQn, 1);
	NVIC_ClearPendingIRQ(RADIO_IRQn);
	NVIC_EnableIRQ(RADIO_IRQn);
}

The RADIO_IRQHandler function is never called. How can I fix this?

PS: I'm not using Nordic's SoftDevice.

Parents
  • In addition to enabling an interrupt in the NVIC, you must also set which events in a peripheral that should generate interrupts. This is done in the INTEN register, accessible through the -SET and -CLR aliases. To for example make the READY- and ADDRESS-events generate interrupts, you'd do this in your init:

    
    void init(void)
    {
        NRF_RADIO->INTENSET = RADIO_INTENSET_READY_Enabled << RADIO_INTENSET_READY_Pos | 
                              RADIO_INTENSET_ADDRESS_Enabled << RADIO_INTENSET_ADDRESS_Pos;
        
    	NVIC_SetPriority(RADIO_IRQn, 1);
    	NVIC_ClearPendingIRQ(RADIO_IRQn);
    	NVIC_EnableIRQ(RADIO_IRQn);
    }
    
    

    Be aware that you can also use the SHORTS register to directly connect an event with a task in the same peripheral.

Reply
  • In addition to enabling an interrupt in the NVIC, you must also set which events in a peripheral that should generate interrupts. This is done in the INTEN register, accessible through the -SET and -CLR aliases. To for example make the READY- and ADDRESS-events generate interrupts, you'd do this in your init:

    
    void init(void)
    {
        NRF_RADIO->INTENSET = RADIO_INTENSET_READY_Enabled << RADIO_INTENSET_READY_Pos | 
                              RADIO_INTENSET_ADDRESS_Enabled << RADIO_INTENSET_ADDRESS_Pos;
        
    	NVIC_SetPriority(RADIO_IRQn, 1);
    	NVIC_ClearPendingIRQ(RADIO_IRQn);
    	NVIC_EnableIRQ(RADIO_IRQn);
    }
    
    

    Be aware that you can also use the SHORTS register to directly connect an event with a task in the same peripheral.

Children
No Data
Related