Having no access to your SPI code can only solicit general replies like this.
Read and Discard:
After the CS line goes high, continuously read any available data from the SPI receive buffer until it is empty. You can use the spi_is_readable() function to check if data is present and spi_read_blocking() to read and discard it.
Dummy Transmission:
Before sending real data, the master can send a few dummy bytes after pulling CS low. The receiver should be programmed to ignore these initial bytes.
PIO FIFO (if applicable):
If you are using the PIO state machines for SPI, you can use the pio_sm_clear_fifos() function to clear both TX and RX FIFOs.
Remember SPI does not say how it should be used by an application, so issues like you described are application related issues sharing your code is encouraged.
Read and Discard:
After the CS line goes high, continuously read any available data from the SPI receive buffer until it is empty. You can use the spi_is_readable() function to check if data is present and spi_read_blocking() to read and discard it.
Dummy Transmission:
Before sending real data, the master can send a few dummy bytes after pulling CS low. The receiver should be programmed to ignore these initial bytes.
PIO FIFO (if applicable):
If you are using the PIO state machines for SPI, you can use the pio_sm_clear_fifos() function to clear both TX and RX FIFOs.
Remember SPI does not say how it should be used by an application, so issues like you described are application related issues sharing your code is encouraged.
Statistics: Posted by Henderson Hood — Thu Apr 17, 2025 1:25 am