Skip to main content
Associate III
November 2, 2024
Question

SPI communication (Receive Only Master)

We are trying to develop a device that uses SPI communication (Receive Only Master).

Are there any sample programs for SPI communication (Receive Only Master)?

Which should be executed first: "Receive Only Master HAL_SPI_Receive" or "Transmit Only Slave"?

I think it is "Receive Only Master HAL_SPI_Receive", is that correct?

This topic has been closed for replies.

3 replies

gbm
Super User
November 2, 2024

Slave must be ready to respond to master, so slave must be started first.

SPI protocol is designed in such a way that slave implementation in a microcontroller may not be easy. Normally, the slave is a logic circuit, always ready for communication with master and able to initialize the session immediately after detecting -SS going low. This is impossible with an MCU.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice
Associate III
November 2, 2024

”slave must be started first.”

I see. That's how it was.

 

Does this mean that "Transmit Only Slave" cannot be achieved with a MUC program?

Is there any way to achieve this by combining the following APIs?

・HAL_SPI_TransmitReceive
・HAL_SPI_Transmit
・HAL_SPI_Receive
・HAL_SPI_TransmitReceive_IT
・HAL_SPI_Transmit_IT
・HAL_SPI_Receive_IT
・HAL_SPI_TransmitReceive_DMA
・HAL_SPI_Transmit_DMA
・HAL_SPI_Receive_DMA
・HAL_SPI_TxCpltCallback

 

PGump.1
Senior II
November 3, 2024

Hi,

Unfortunately, you are looking for a "crisp" black-white answer. But there is not one for the description you have given. There are many subtle differences between the different modes that may or may not suit your application.

You really need to read the Reference Manual for your device to assist with good choices...

Kind regards
Pedro

AI = Artificial Intelligence, NI = No Intelligence, RI = Real Intelligence.