Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SPI Transaction Manager transfer results in unexpected transaction length

I am using the nRF SPI Transaction Manager (nrf_spi_mngr.c) and the SPI transfer (nrf_spi_mngr_transfer_t) isn't performing as expected.

I expect the following code to result in a single-byte transfer, where the value '0x15' is transmitted, and the byte that is simultaneously received to be stored within the 'rx_buf' variable.

uint8_t cmd = 0x15;         // register to write to to the SPI slave
uint8_t rx_buf = 0x00;      // buffer to store response

// create transfer to write a cmd and read a byte
nrf_spi_mngr_transfer_t transfer = NRF_SPI_MNGR_TRANSFER(&cmd, 1, &rx_buf, 1);

// perform transfer
nrf_spi_mngr_perform(&m_nrf_spi_mngr, NULL, &transfer, 1, NULL);

However, the data log in the image below shows the actual output, where the transaction consists of a 2-byte transfer, and the variable 'rx_buf' now holds the value '0x00'.

Furthermore, in the following code (p_tx_data = NULL, tx_length = 0), I would expect a single transfer of 1-byte, where the over-run char is transmitted, and the simultaneously received byte is stored within the 'rx_buf' variable.

uint8_t rx_buf = 0x00;      // buffer to store response

// create transfer to read a single byte
nrf_spi_mngr_transfer_t transfer = NRF_SPI_MNGR_TRANSFER(NULL, 0, &rx_buf, 1);

// perform transfer
nrf_spi_mngr_perform(&m_nrf_spi_mngr, NULL, &transfer, 1, NULL);

However this also results in a 2-byte transfer (see image below).

SDK: nRF5SDK160098a08e2

Related