Hi all,
I'm working with the reception of 802.15.4 packets on nRF52840 for which I have configure the radio as follows:
//PHR length in bits #define PACKET_LENGTH_FIELD_SIZE (8UL) //Max ota frame size for O-QPSK modulation #define MAX_OTA_FRAME_SIZE 127 //Buffer for frames to be received: 127 MAX PSDU size + PHR size static uint8_t radioPacketBuffer[MAX_OTA_FRAME_SIZE + 1]; void RADIO_IRQHandler(void) { //Is the radio ready if(NRF_RADIO->EVENTS_READY == 1U) { NRF_RADIO->EVENTS_READY = 0; NRF_RADIO->EVENTS_END = 0U; // Start listening and wait for end of reception event NRF_RADIO->TASKS_START = 1U; } if(NRF_RADIO->EVENTS_END == 1U) { NRF_RADIO->EVENTS_END = 0; //Get the timestamp NRF_TIMER1->TASKS_CAPTURE[0] = 1; //Check if the checksum is correct if (NRF_RADIO->CRCSTATUS == 1U) { OTAFrameValidReceivedFlag = true; } StartRxRadioFlag = true; } } void radioInit(void) { // Set radio configuration parameters NRF_RADIO->SHORTS = 0; NRF_RADIO->TXPOWER = 0; NRF_RADIO->MODE = (RADIO_MODE_MODE_Ieee802154_250Kbit << RADIO_MODE_MODE_Pos); // Packet configuration NRF_RADIO->PCNF0 = (PACKET_LENGTH_FIELD_SIZE << RADIO_PCNF0_LFLEN_Pos) | (RADIO_PCNF0_CRCINC_Include << RADIO_PCNF0_CRCINC_Pos) | (RADIO_PCNF0_PLEN_32bitZero << RADIO_PCNF0_PLEN_Pos) ; // Packet configuration NRF_RADIO->PCNF1 = MAX_OTA_FRAME_SIZE; // Radio address config NRF_RADIO->BASE0 = 0; NRF_RADIO->BASE1 = 0; NRF_RADIO->PREFIX0 = 0; NRF_RADIO->PREFIX1 = 0; // CRC Config NRF_RADIO->CRCCNF = (RADIO_CRCCNF_LEN_Two << RADIO_CRCCNF_LEN_Pos) | (RADIO_CRCCNF_SKIPADDR_Ieee802154 << RADIO_CRCCNF_SKIPADDR_Pos); // Number of checksum bits NRF_RADIO->CRCINIT = 0; // Initial value NRF_RADIO->CRCPOLY = 0x11021UL; // CRC poly: x^16 + x^12^x^5 + 1 NRF_RADIO->TIFS = 0; //NRF_RADIO->DATAWHITEIV = 0x40; NRF_RADIO->BCC = 0x18; NRF_RADIO->DACNF = 0; NRF_RADIO->MHRMATCHCONF = 0; //This was taken from ZR on running state, not really sure what it does... nrf spec does not provide help about it... NRF_RADIO->MHRMATCHMAS = 0xff000700; //This was taken from ZR on running state, not really sure what it does... nrf spec does not provide help about it... NRF_RADIO->MODECNF0 = (RADIO_MODECNF0_RU_Fast << RADIO_MODECNF0_RU_Pos) | (RADIO_MODECNF0_DTX_Center << RADIO_MODECNF0_DTX_Pos); //802.15.4 configration NRF_RADIO->SFD = 0xA7; NRF_RADIO->EDCNT = 0; NRF_RADIO->EDSAMPLE = 0; NRF_RADIO->CCACTRL = 0x02141400; //From ZR configuration... NRF_RADIO->POWER = 1; NRF_RADIO->PACKETPTR = (uint32_t)&radioPacketBuffer; NRF_RADIO->FREQUENCY = 5UL; NRF_RADIO->INTENSET = RADIO_INTENSET_READY_Enabled << RADIO_INTENSET_READY_Pos | RADIO_INTENSET_END_Enabled << RADIO_INTENSET_END_Pos; NVIC_SetPriority(RADIO_IRQn, 1); NVIC_ClearPendingIRQ(RADIO_IRQn); NVIC_EnableIRQ(RADIO_IRQn); }
In the application loop we have:
if(OTAFrameValidReceivedFlag) { timestamp = NRF_TIMER1->CC[0]; OTAFrameValidReceivedFlag = false; /* ... SOME CODE THAT PROCESS THE CONTENT OF radioPacketBuffer ... */ memset(radioPacketBuffer,0,sizeof(radioPacketBuffer)); //valid frame received! bsp_board_led_invert(0); } if(radioActive & StartRxRadioFlag) { // Start listening again NRF_RADIO->TASKS_START = 1U; }
we receive frames and transmit frames properly, but there is sometimes in which we receive frames in radioPacketBuffer, which payload is bigger than 127, this is readed in radioPacketBuffer[0].
According to 802.15.4 for O-QPSK the max payload is 127 bytes, all the frames we received seems fine, but as soon we start capturing on populated networks we see this kind of behavior which is causing the device to fail.
Has this happened to anyone?, do we have a wrong configuration to capture packets?