cancel
Showing results for 
Search instead for 
Did you mean: 

Extra SPI Clock Pulse on Initial Transfer

jon_magnussen
Associate
Posted on February 11, 2016 at 14:24

I am using an STM32L152 with the HAL library. I initialize the spi bus similar to the example code from STM32CubeMx. However, the very first spi transaction always has a wide extra clock pulse (see attachment). Any idea what might cause this?

SpiHandle.Instance = SPI1;
SpiHandle.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_256;
SpiHandle.Init.Direction = SPI_DIRECTION_2LINES;
SpiHandle.Init.CLKPhase = SPI_PHASE_1EDGE;
SpiHandle.Init.CLKPolarity = SPI_POLARITY_LOW;
SpiHandle.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
SpiHandle.Init.DataSize = SPI_DATASIZE_8BIT;
SpiHandle.Init.FirstBit = SPI_FIRSTBIT_MSB;
SpiHandle.Init.NSS = SPI_NSS_SOFT;
SpiHandle.Init.TIMode = SPI_TIMODE_DISABLE;
SpiHandle.Init.Mode = SPI_MODE_MASTER;
if
(HAL_SPI_Init(&SpiHandle) != HAL_OK)

1 REPLY 1
Posted on February 11, 2016 at 18:12

> Any idea what might cause this?

Something in your code before SPI initialization?

Set up a spare pin as GPIO output and toggle it just before and just after the SPI initialization, and trace it together with the SPI pins on your LA.

JW