AnsweredAssumed Answered

SPI slave doesn't transmit, STM32F407VE

Question asked by Ivan Feoctistov on Mar 21, 2018
Latest reply on Mar 22, 2018 by Ivan Feoctistov

I have STM32F103C8 as a SPI master and a STM32F407VE as a SPI slave.

I haven't worked with SPI enough to find optimal way to write communication mechanism, and earlier work with SPI only on AVR and Texas Instruments C2000 platforms, so STM32 is new for me.

That's what I remember about SPI: Master initializes communication, sends data by MOSI with CLK. Slave can answer to request only when master will send something. So - slave should be ready to push data by MISO when CLK will appear. Hope that's right.

Transmission and receiving by interrupt works fine. F103 transmits by command HAL_SPI_Transmit() to F407, which receiving data in ISR, every byte, no troubles.


But now's my headache begins.

Master sends command to slave to get ready for answer. Slave collects data in one array and pushes it to transmit buffer. Master, after 1ms delay sends zeroes to slave just to receive whole array of data from slave. '\n' means the end of transmission.


So how I should organize that?

Slave receiving command to get ready, that's alright.

Slave collected data in one array.

What should be next?

I use command HAL_SPI_Transmit() and push there whole array. As I hope - this data will be held in SPITx buffer, and when CLK appears - will be pushed through MISO until master stops communication. 

But it's not working like that. Master receiving nothing.


The question is: How slave should transmit data to master? When? What functions should be used?


P.S. Using STM32CubeMX, it means - HAL lib, as you can see.