Electronic – STM32F2xx: Data from SPI Slave to Master

spistm32

I have a STM32F2xx connected to a FTDI UM232H using SPI, STM32F2xx will be configured as SLAVE and FTDI will be configured as MASTER

My scenario is this, I am getting data in STM32F2xx, and when I received data I would like to send it to my FTDI using SPI

But, how can a slave SPI send to Master??? since to initiate the communication, it needs the SCLK, which is controlled by the master

So how can I do that?

Or my master needs to constantly read the SPI Slave??? (like polling method) or is there any better way to do ti??

My current configuration for my SPI is:

  1. 2 line duplex
  2. 1 Mhz clock
  3. MSB
  4. 8 bit
  5. Phase = Low
  6. Polarity = Positive
  7. Hardware: 4 lines connection, CS, SCLK, MOSI, MISO

Best Answer

The master always controls the clock. In the most basic SPI implementation, the master clocks 8 times and the slave outputs a single byte. If the slave has more output, the master must ask for it.

It is possible to have an external interrupt that the slave triggers when it has data for the master, but again the master controls the clock and must clock the data out of the slave. But this only works if the master supports such an interrupt, which the FT232H does not.