cancel
Showing results for 
Search instead for 
Did you mean: 

Wrong data read, STM32f0 communicating with a stm32f0-discovery

sebastien23
Associate II
Posted on August 26, 2015 at 10:07

Hi, i'm getting stuck in my work. What i do is simple, i make a STM32F030F4P6 communicating with a STM32F0-discovery board by SPI. The STM32F030F4P6 is the master and the discovery is the slave. All initializing have been done correctly.

My problem is that when the master sends a data on the MOSI line, the slave misunderstand it and see a wrong data. Whenever i look on an oscilloscope i see the right data on the MOSI line but checking on the register of the discovery made me realize that it does see another data.

I can't explain why it's seeing a wrong data, so if somebody already had this kind of problem or if you know what could fix it, please let me know. I really need to get this work as soon as possible. And if you need a code sample don't hesitate!

Thank you.

#spi #discovery #stm32f0
2 REPLIES 2
jpeacock
Associate III
Posted on August 27, 2015 at 14:16

Are the SPI receive data registers clear before you start?  Remember SPI is bi-directional, transmitting also clocks in data at the same time.

Your receiver board should have it's TX register loaded, waiting for the transmitter board to send on MOSI and at the same time shift in data on the MISO line connected to the receiver's MOSI.

  Jack Peacock

jaimadafaca
Associate II
Posted on August 27, 2015 at 15:42

I’m having similar problems whit SPI and my STM32F030.

Very odd, because I see on oscilloscope I see the right data, but in my read register seems to be the data “misaligned�?  (it looks random)

I’ve checked differences between library stm32f0xx_hal_spi.c with previous versions and there are slightly changes. 

I tried to use old libraries (that I use in other project in which the SPI works perfectly), and doesn’t work too.

So I don’t know what to do.

If anybody could throw some of light …I’d be pleased.

I use stm32f0xx_hal_spi.c version :

  * @version V1.2.0

  * @date    11-December-2014

What are you using?

Thanks in advance,

Best regards.