Hi all !
I'm struggling to get a frequency jumping protocol up and running and can't figure out how to handle the following situation (please refer to the attached "pseudo code"):
1. When I start the radio to receive(or transmit) a packet I assert that it is "DISABLED".
2. When I get a radio interrupt I assert that the radio is "RXIDLE" (or TXIDLE).
3.When a packet has been received (or transmitted) I disable the radio.
After a couple of successful receptions (frequency changed between each one of them) I suddenly fall in to the default case of the switch in the ISR, i.e. ASSERT(false). When I check the value of the variable "state" it is 1, i.e. RXRU (In the debugger the NRF_RADIO->STATE has value 3, i.e. RXIDLE, but that seems logical).
My question is this: How can a packet be received when the radio is still in RXRU ? I guess the solution here would simply be to enable the receiver a bit earlier but still, is this behavior really to be expected ?
Cheers
Eric
void RADIO_Init(void)
{
//...
// Enable interrupt from END event
NRF_RADIO->INTENSET = 0x00000008;
}
/*===========================================================================*/
void RADIO_Start(radioMode_e mode)
{
ASSERT(NRF_RADIO->STATE == STATE_DISABLED)
switch (mode)
{
case RADIO_MODE_RX:
NRF_RADIO->TASKS_RXEN = 1;
break;
case RADIO_MODE_TX:
NRF_RADIO->TASKS_TXEN = 1;
break;
default:
ASSERT(false);
break;
}
}
/*===========================================================================*/
void RADIO_IRQHandler(void)
{
uint32_t state;
if (NRF_RADIO->EVENTS_END)
{
NRF_RADIO->EVENTS_END = 0;
NRF_RADIO->EVENTS_END;
state = NRF_RADIO->STATE;
switch (NRF_RADIO->STATE)
{
case STATE_RXIDLE:
// Packet received....
break;
case STATE_TXIDLE:
// Packet sent....
break;
default:
ASSERT(false);
break;
}
NRF_RADIO->TASKS_DISABLE = 1;
}
}