Little bits of progress on NRF24

It's been so long since I posted about this I had to go back and look at what I'd last written. I've covered a lot of territory.

Recently, the NRF24L01+ driver I'm using has proved problematic, as has the data sheet itself: It doesn't make it clear if FLUSH_TX or FLUSH_RX delete all the contents of a fifo, or just the next item.

From this in the product specification, you might think just the next item:
Note: Always check if the packet width reported is 32 bytes or shorter when using the
R_RX_PL_WID command. If its width is longer than 32 bytes then the packet contains errors and must be discarded. Discard the packet by using the Flush_RX command.
Otherwise it's a bit ridiculous: why would you discard valid packets from the receive buffer to get rid of one invalid packet at the head? Actually FLUSH_RX does flush everything. Why would you suggest that when you can discard a single packet by just aborting an R_RX_PAYLOAD? There are perhaps a reason for this: dumb SPI implementation (e.g. Linux) might not deselect (raise CS) to reliably abort the transaction.

deselecting does seem to abort the transaction - and that's how I've dealt with it.

Actually, why is this a special case at all? Why doesn't the packet just get discarded? I guess it was deemed wildly improbably it would ever happen, until someone noticed it happen.

The driver's getDynamicPayloadSize() has this horror in it:
  if(result > 32) { flush_rx(); delay(2); return 0; }
  return result;
Which means you can't tell from the return result if the FLUSH_RX has occurred or not. That R_RX_PL_WID can return 0 seems to have been ignored, but I've seen it happen, and of course it just leaves you in a loop trying to read the packet - the length is zero, so you skip the read, but it isn't flushed.

Popular posts from this blog

3D Printer ramblings

Balance Bot V2

Robot arm