SPI writes extra 0x20 between each byte when transmitting data packets

Program SPI write b77393092e36ab7e06f46dcde81a2074

When capturing SPI data, the following is displayed:

Code calling the interface:

The rt_spi_send_then_recv() function you are using performs two separate transfers. The first transfer sends data and then discards the received data. The second transfer does not fill the transmit data register with valid data, which effectively generates only 8 clock pulses to receive one byte from the slave device. In this case, the data on MOSI is meaningless.

The operation code and parameters should be sent continuously in one transmission. During a complete transmission, NSS should remain low throughout and does not need additional configuration. For example:

uint8_t buf[] = {opcode, para, ...};

rt_spi_transfer(spi_dev_handle, buf, NULL, sizeof(buf));

For more information about SPI-related APIs, please visit:

Alternatively, feel free to post further questions.