cancel
Showing results for 
Search instead for 
Did you mean: 

One bit shift in SPI communication on STM32H7

Gpeti
Senior II

I'm working on SPI communication between two Nucleo-H743ZI boards. I'm using ST's HAL, and the SPI polling API HAL_SPI_TransmitReceive.

It's working fine until a bandwith of 12Mbits/s (SPI kernel clock at 200Mhz and prescaler 16, the CPU is always at 400Mhz) but fails above (smaller prescaler).

I want to understand since 24 or 48 Mbits/s doesn't seem much even in polling with a poor quality software.

With prescaler set to 8, I don't have SPI error like overrun or other (I checked directly in registers), however the data are not correct. looking closer to the data, I've noticed that there is only a shift of one bit.

More precisely I should receive (in hexa :( 0x30 0x31 0x32 ... And I receive 0x18 0x18 0x99...

In binary:

  • expected 0011 0000 0011 0001 0011 0010...
  • received 0001 1000 0001 1000 1001 1001...

If I shift the received bitstream to the left I get exactly the right result.

Does it ring something to you ? Could it be due to a bad configuration ?

Obviously master and slave have the same configuration regarding phase and polarity (and everything else since the source code is mostly identical).

This discussion is locked. Please start a new topic to ask your question.
10 REPLIES 10
sireevenkat1
Senior

Thanks for the reply ,

I changed SPI prescaler from 64 to 256 ,Now I can able to read correct values from few registers(ATM90E26 is energy meter IC).Now I can able to read frequency & meter status registers correctly. But If I read voltage and current registers I am always getting value zero values.
In ATM90E26 datasheet SPI Interface Bit Rate  max is 160K Bps.

In my configuration 96Mhz(system clock)/256(prescaler)=375 kbps.
Is the issue with Bit rate? Can anyone clarify me ?
Because I can able to read few registers of ATM90E26 correctly & few registers I can't able to read.
Thanks