Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8609

General • SPI write from Slave device

$
0
0
Hi Guys,

I now have an SPI slave that is able to receive a command from a host device (C64 in this case).

But I am now trying to get the Slave to send two bytes back to the C64, like so.

Code:

spi_read_blocking(SPI_PORT, 0, read_command, 4);// Reads and decodes the command happily..........spi_write_blocking(SPI_PORT, response, 2);// Respond by sending back two bytes
This compiles and runs ok, but I have found that from the host (after lots of trial and error / debugging), that in order to receive both bytes from the slave, I have to pulse the clock and additional 8 times between the spi_read and spi_write commands, otherwise the Master only receives the first byte of the response.

Is this normal behaviour?

Many thanks.

Statistics: Posted by Lonewolff — Fri Apr 18, 2025 6:04 am



Viewing all articles
Browse latest Browse all 8609

Trending Articles