2018-04-05 07:01 AM
Hello.
I'm trying to establish SPI connection between the STM32l151 MCU and a linux-powered processor module. The MCU is located on a custom PCB and acts as a slave, the CPU is a master. Connection speed s 100 kHz.
The problem is that data is not correctly received or transmitted by MCU and seems to be shifted by a random number of bits. I send 0x80 0x80 0x80 0x80 parcel, verify that it is transmitted correctly using the oscilloscope, and receive various wrong parcels like 0x80 0x02 0x08 0x04 and so on.
I tried to connect STM32L476 discovery board to the CPU board and the problem remains the same.
But on a STM32F401 everything works fine. The transmission code is the same among all the used platforms, the only difference is used CubeMX package for the particular device. SPI peripheral is configured the same way, connection scheme is also common.
The c code is attached, as well as sample cubemx configuration for stm32l476.
#discovery #hal-spi #spi-slave #stm32l2018-04-05 07:44 AM
Possibly SCK oscillations/bouncing, due to 1.inadequate grounds (each signal has to have its own ground, interspersed between signals); 2. too long lines, 3. inadequate line termination.
Add ground lines, shorten connection cable, add series resistors at both ends.
JW
2018-04-05 08:50 AM
Hello Jan,
Thanks for help. The ground is continious on PCB and properly connected on both discovery board assemblies. It is strange that SPI doesn't work properly on PCB with short lines with proper termination but works fine with discovery stm32f4 board with long connecting wires. I also tried to lower SPI master speed to 10kHz and it changed absolutely nothing. I use the oscilloscope to conrol signal integrity on all lines and it is fine in all cases.
Forgot to mention that hardware NSS is used. Disabling NSS feature, though, doesn't make any changes.