I want to use the radio interrupt to receive data, but I only entered the interrupt once at initialization, and I can't enter the interrupt again.
But use the commented out code,I can get the data.
thanks!
Here's my code:
#include "sdk_common.h"
#include "radio_config.h"
uint8_t packet[3]={'Q','0','C'};
void Radio_init(void)
{
NRF_RADIO->INTENSET = 0xF;
NVIC_SetPriority(RADIO_IRQn, 1);
NVIC_ClearPendingIRQ(RADIO_IRQn);
NVIC_EnableIRQ(RADIO_IRQn);
NRF_RADIO->TASKS_RXEN = 1;
}
int main(void)
{
volatile int ss;
NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
NRF_CLOCK->TASKS_HFCLKSTART = 1;
while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0)
{}
radio_configure();
Radio_init();
NRF_RADIO->PACKETPTR = (uint32_t)packet;
while (1)
{
// NRF_RADIO->EVENTS_READY = 0U;
// NRF_RADIO->TASKS_RXEN = 1U;
// while(NRF_RADIO->EVENTS_READY == 0U)
// {}
// NRF_RADIO->EVENTS_END = 0U;
// NRF_RADIO->TASKS_START = 1U;
// while(NRF_RADIO->EVENTS_END == 0U)
// {}
// if (NRF_RADIO->CRCSTATUS == 1U)
// {
// ss=packet[1];
// }
// NRF_RADIO->EVENTS_DISABLED = 0U;
// NRF_RADIO->TASKS_DISABLE = 1U;
// while(NRF_RADIO->EVENTS_DISABLED == 0U)
// {}
}
}
void RADIO_IRQHandler()
{
int ss;
if(NRF_RADIO->EVENTS_READY && (NRF_RADIO->INTENSET & RADIO_INTENSET_READY_Msk))
{
NRF_RADIO->EVENTS_READY = 0;
}
if(NRF_RADIO->EVENTS_END && (NRF_RADIO->INTENSET & RADIO_INTENSET_END_Msk))
{
NRF_RADIO->EVENTS_END = 0;
}
if(NRF_RADIO->EVENTS_ADDRESS && (NRF_RADIO->INTENSET & RADIO_INTENSET_ADDRESS_Msk))
{
NRF_RADIO->EVENTS_ADDRESS= 0;
}
if(NRF_RADIO->CRCSTATUS == 1)
{
ss=packet[1];
}
}