Hi everyone,
I am implementing a custom protocol using the NRF52 radio, and so far I was able to make the transmitter working as expected.
In a nutshell, the protocol is based on carrier sensing, so every xx milliseconds the received reads the RSSI and if this is above a given threshold it means that a transmission is ongoing and it receives the packet. The problem is that when the reception is invoked, the received is stuck in the reception loop indefinitely.
My code was based on the radio examples from the SDK, so the reception is essentially realized as follows
NRF_RADIO->EVENTS_DISABLED = 0; NRF_RADIO->TASKS_DISABLE = 1; while(NRF_RADIO->EVENTS_DISABLED == 0); NRF_RADIO->EVENTS_READY = 0; NRF_RADIO->TASKS_RXEN = 1; while (NRF_RADIO->EVENTS_READY == 0){} //Wait while radio is ramping up. NRF_RADIO->PACKETPTR = (uint32_t)buf; NRF_RADIO->EVENTS_END = 0; // Start listening and wait for address received event NRF_RADIO->TASKS_START = 1; // Wait for end of packet or buttons state changed while (NRF_RADIO->EVENTS_END == 0) { // wait }
As said, my code is stuck in the last while loop. It is possible that the reception never happens (a wrong rssi detection, or a later switch to rx mode), but if this is the case will the radio stay in the loop forever? Isn't there a way to stop the reception after some time if no reception happens?
Thanks a lot for your help.