2024-01-02 12:28 PM
Hello,
I'm trying to send a message from slave to master using spi (I'm using only one stm board) and so far nothing I tried has worked. AFAIK for the slave to send data to master, the master has to initiate communication first by sending clock signals, and dummy bytes.
1) To be able to send data from slave to master, is Full Duplex is a must (for purpose of Master to send dummy bytes while simultanously receiving bytes)?
2) I tried using HAL_SPI_TransmitRecieve() in Master size but I'm not sure what function should I use with the slave, and what is the order of function calls.
I would appreciate your help,
Thanks!
2024-01-02 12:45 PM
Hello @Jordalic
I suggest you to start from an example that use SPI for master to slave communication between 2 boards. Than use the master configuration for the spi master (spi 1 for example) and the slave configuration for the spi slave (spi 2 for example).
Best Regards.
STTwo-32
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-01-02 12:53 PM
The slave would also use HAL_SPI_TransmitRecieve()
But you'll be one byte behind, so typically you'd initially respond with a dummy byte, and then receive a "register" or "command" type byte, or bytes, from the Master indicating what it is you're trying to communicate. This allows the Slave to determine what type of response is expected.
2024-01-02 03:07 PM
Actually I tried sending messages from master to slave with no problem at all. I find that the otherway around is more tricky because slave cannot initiate transactions and the master need to send dummy data first and only than read the data of the slave.
2024-01-02 03:09 PM
Are you referring to Full Duplex SPI?