I have for some while had a project running in which NRF52840 operates in SPI slave mode. Using "modules\hal\nordic\nrfx\drivers\src\nrfx_spis.c"
Lately i have been stressing the system with higher data throughput in both direction and is observing packet loss in RX direction.
I have tracked it down and it seems that in the SPI event handler when processing NRFX_SPIS_XFER_DONE data in rx buffer is incorrect/empty.
In the "spis_irq_handler" the following is stated:
// @note: as multiple events can be pending for processing, the correct event processing order
// is as follows:
// - SPI semaphore acquired event.
// - SPI transaction complete event.
In the situation when semaphore is requested (asynchronously) while transfer is ongoing (buffer set #1), this means that as soon as transfer is done, both events will be pending, and the "acquired" event is processed first, and new buffer set #2 for next transaction are configured.
Next the transaction complete action is processed, but it now seems uncertain if the NRFX_SPIS_XFER_DONE event corresponds to the buffer set (#1) initial configured or the one (#2) recently setup during "acquired event" processing. Content of the current configured buffer(#2) will in this case be empty leading to the packet loss I observe.
Reversing the order in the "isr" seems to solve the issue and to me it also seems logical to process the completed transaction before setting up new buffers and not the other way around.
Are you able to elaborate a bit on why the order described in the isr routine should be the correct one ?