How to get an interrupt when the radio is used (TX, RX, etc)

Hi my friends,

I have been trying to get a grasp of how I can work with the interrupt signals.
I have read a few posts on the Devzone such as [Ref 1] and [Ref 2] and tried to adopt the same approach to test my understanding.

Assuming that the NRF_RADIO peripheral monitors the interrupt signals, I wrote the following code to see if I get an interrupt when the radio is being used.

Creating the interrupt handler, which just logs the fact that it was fired:

void RADIO_IRQHandler(void)
{	
	LOG_INF("RADIO IRQHandler Fired!!!\n");
}

Configuring the interrupt using the NRF_RADIO peripheral

void intrupt_CFG(void)
{
	NRF_RADIO->INTENSET = RADIO_INTENSET_READY_Enabled << RADIO_INTENSET_READY_Pos | 
                          RADIO_INTENSET_ADDRESS_Enabled << RADIO_INTENSET_ADDRESS_Pos | RADIO_INTENSET_END_Msk;

	NVIC_SetPriority(RADIO_IRQn, 1);
	NVIC_ClearPendingIRQ(RADIO_IRQn);
	NVIC_EnableIRQ(RADIO_IRQn);
}

The main code which activates the bluetooth and scans for some time and then it disables the bluetooth:

int main(void)
{

	intrupt_CFG();

	int err;

	err = bt_enable(NULL);
	if (err) {
		printk("Bluetooth init failed (err %d)\n", err);
		return 0;
	}

	printk("Bluetooth initialized\n");

	start_scan();

	int Duty_Cycle = 250;
	k_sleep(K_MSEC(Duty_Cycle));

	bt_le_scan_stop();
	bt_disable();

	printk("Bluetooth Disabled \n");

	return 0;
}

However, when I build and flash, the log information (serial port) does not show that "RADIO_IRQHandler" has been triggered. 


Any help would be much appreciated, thanks.

Parents Reply Children
  • Hi 

    The cases you refer to are older cases based on the nRF5 SDK. In nRF Connect SDK interrupt handling is a bit different, since you have the Zephyr RTOS running underneath, rather than writing the code bare metal. 

    For a reference how to enable the radio interrupt you could have a look at the ESB protocol, which is one of the proprietary 2.4GHz based protocols provided in the new SDK. 

    For instance, interrupt initialization is handled here.

    The radio interrupt itself is implemented here, but the code that will be run is implemented in the radio_irq_handler function implemented here.

    Still, when you are running Bluetooth the NRF_RADIO peripheral and the RADIO interrupt will be reserved for the Bluetooth stack, and will not be available to the application. In other words it will not work to first configure the radio interrupt and then start the Bluetooth stack, at this point the radio interrupt will be handled by the stack directly. 

    If you want to run a proprietary 2.4GHz based protocol you need to disable Bluetooth first, or use the timeslot API to get access to the radio in between Bluetooth events. 

    In order to allow us to assist you more effectively, maybe you could provide a short description of the application you are trying to implement, and why you want to access the radio interrupt directly when using the Bluetooth stack?

    Best regards
    Torbjørn 

Related