2021-06-05 01:30 AM
Hello,
i currently use SPI interface of my STM32H7B3I board with DMA (mode circular) to build up a connection to Raspberry Zero W (using Python spidev-lib).
At the beginning, I start HAL_SPI_TransmitReceive_DMA() where the data exchange is initialized.
From then it transfers the bytes (8 for now). But from every transmission cycle the RX-Bytes are shifted left on Raspberry RX and right shifted on STM32 RX.
I tried using normal mode but then only one transmission is done and I havent figured out yet how to clear the responding bits manually.
STM32 is slave (full duplex) and Raspberry is master.
Any ideas?
If you need further informations let me now.
Regards
Clemens
2021-06-05 03:50 AM
One bit shift? That's hardly related to DMA.
Observe the signals using LA. Check CPOL and CPHA settings on both sides. Make sure NSS goes active (i.e. low) when click is in its idle state.
JW
2021-06-05 03:54 AM
one byte shift
2021-06-05 05:13 AM
Then STM32 missed the first frame. How do you synchronize the two devices? Toggle an output pin just after calling the Cube function which starts the communication, and observe it together with the rest of the signals.
JW
2021-06-05 06:11 AM
I wait for the Raspberry (master) to pull the CS to low. Then I call HAL_SPI_TransmitReceive_DMA().
If I just transmit from STM (Slave) to Raspi (Master) the Communication works and vice versa.
2021-06-05 06:27 AM
You should call HAL_SPI_TransmitReceive_DMA before CS goes low. Otherwise, you need to put a delay between CS going low and the first byte sent in order for the slave to be ready.
2021-06-06 06:16 AM
Thank you guys.
So I have to add two extra pins that syncs the two devices? Like this:
Further raspberry has to care about error handling.
Or maybe i should switch the raspberry spi-lib :grinning_face_with_sweat: