In playing around with NRF24 devices connected to Nucleos, I came across a bug of some kind yesterday.
The symptoms seem to be:
This only happens sometimes, it will run fine for tens of minutes message flow is fine.
I had the NRF's number of auto-ack retries set to 5 but reduced that to 1 and the issue seems to have gone (or perhaps is now rarer).
After pondering I wondered if this is a scenario:
The TX sends message, the RX gets it and auto sends an Ack.
The TX does not get that Ack for some reason and so resends the message about 250 uS later.
The message arrives and the RX interrupt handler runs, while the main code is in the process of reading data pertaining to the received message.
The odd thing now is, that if the TX really was missing sent Acks, it would report that (because it's coded to do so) but it isn't...
The symptoms seem to be:
- The MCU gets and handles an interrupt corresponding to a received payload.
- The MCU clears the interrupt flags on the NRF's STATUS register.
- The Handler exits and the "main" code resumes and begins to read the payload.
- During that operation another interrupt arrives.
- The MCU app fails (because HAL was entered while reading the payload and HAL was entered concurrently as the handler clears the flags.
This only happens sometimes, it will run fine for tens of minutes message flow is fine.
I had the NRF's number of auto-ack retries set to 5 but reduced that to 1 and the issue seems to have gone (or perhaps is now rarer).
After pondering I wondered if this is a scenario:
The TX sends message, the RX gets it and auto sends an Ack.
The TX does not get that Ack for some reason and so resends the message about 250 uS later.
The message arrives and the RX interrupt handler runs, while the main code is in the process of reading data pertaining to the received message.
The odd thing now is, that if the TX really was missing sent Acks, it would report that (because it's coded to do so) but it isn't...
