This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Why is event.rx_amount always 0 in spi_slave example?

Hello all

If you could please point me some directions on how to solve my issue, I would be grateful:

Some background info:

SDK used: 9.0

  • spi master code = example code, spi_master_with_spi_slave
  • spi slave code = example code, spi_slave
  • SPI Master board = PCA10028
  • SPI Slave board = custom board, NRF51822
  • Custom board HW is OK.

Description:

  1. PCA10028 is programmed as spi master, working properly.
  2. Custom board programmed as spi slave. When debugging, code enters SPI_SLAVE_XFER_DONE. When performing if (event.rx_amount == RX_BUF_SIZE) statement, program issues an error, as rx_amount is equal to 0 (always equal to zero...) and RX_BUF_SIZE is not zero.
  3. SPI slave pins have been changed to match used pins in custom board.

Doubt/problems:

Even if spi slave driver SPI_SLAVE_XFER_DONE occurs, no valid data is found in RX buffer. Also, rx_amount is not equal to the amount of data transferred by master.

Thanks for the time reading.

Regards

  • Have you checked the SDK functions at the lowest level? I found with the 11.0 SDK from nordic that for the SPI slave the "nrf_spis_tx_amount_get" and "nrf_spis_rx_amount_get" were referencing the incorrect registers. For TX it was using AMOUNTRX instead of AMOUNTTX and vice versa.

  • Hi! Yes! In SDK 9.0 and lower they are set as: NRF_SPIS1->MAXRX = m_spi_rx_buf_size NRF_SPIS1->MAXTX = m_spi_tx_buf_size both set as '1' in my application

  • Hi, This sounds strange. You say that you have set the buffer sizes to '1'. Have you changed anything else? Have you tried the examples without changing anything? They should work out of-the-box (after assigning the correct pins of course).