Can not read from SPI Rx buffer (STM32f103C8T6)

Thread Starter

GergoT

Joined Jul 24, 2017
8
Hey guys!
I have an STM32 micro as a slave device, and I am communicating with a slave chip through the SPI interface. It works well, so far I can read from the slave's memory cells, I can see the answer on the oscilloscope. But somehow I'm not able to read out this data from the buffer. Here is the code, I hope somebody can see what I'm missing. I put it in a loop, which quits when theres any data.

Képkivágás.PNG
 
Last edited by a moderator:

MrChips

Joined Oct 2, 2009
30,808
Have you initialized all of the related hardware modules correctly?
I see that you are writing directly to hardware registers. Is there a reason for doing this rather than using a peripheral library function?
 

Thread Starter

GergoT

Joined Jul 24, 2017
8
Have you initialized all of the related hardware modules correctly?
I see that you are writing directly to hardware registers. Is there a reason for doing this rather than using a peripheral library function?
It's already solved. Yes I initialized it correctly. The problem was, that one have to read from the SPI->DR register even before the last transfer, in order to clear the overflow flag, so it will receive more data. Otherwise it wont.

Well, I use Standard Peripheral Library, and the function for transfering data contains simply a write to the SPI->DR data register only. So I could just go with this as well.
 
Top