Showing results for 
Search instead for 
Did you mean: 

Problem when using SPI1 controller on the STM32L053C8

Posted on September 09, 2015 at 16:31

I have a problem when using SPI1 controller on the STM32L053C8 Discovery board.  Is there anyone who can provide support on this issue?

Brief description: Occasional bit errors on SPI MISO


16-bit ADC 

connected on SPI1, with STM32L053C8 as the master. One start byte is written on MOSI to trigger start of conversion. 51ms later, two bytes (MSB first) is read on MISO to read the converted value.


Occasional bit errors on MISO in SPI1 data register on STM32L053C8 Discovery board when data over USB (CDC) is transmitted/received. The bit error is mostly seen on the MSB bit (is �0� on oscilloscope, but �1� in SPI1 data register).


I have tried connect SPI1 on both PA5-PA7 and PB3-PB5 with same results.




I have tested to connect the ADC on SPI2 with exactly the same configuration. On SPI2 no bit errors are seen.


- What is the difference between SPI1 and the SPI2 controller with respect to simultaneous  USB communication?

- Are you aware of any issues with the SPI1 controller, which are not occurring when using exactly the same configuration on SPI2? Nothing found in errata sheet DM00114891 related to this issue.

- Are you aware of any setup that could lead to bit errors on SPI1 MISO, but not on SPI2 MISO?

Detailed description:

SPI  configuration:

    spi.Instance = SPI1;

    spi.Init.Mode               = SPI_MODE_MASTER;

    spi.Init.Direction          = SPI_DIRECTION_2LINES;

    spi.Init.DataSize           = SPI_DATASIZE_8BIT;

    spi.Init.CLKPolarity        = SPI_POLARITY_LOW;

    spi.Init.CLKPhase           = SPI_PHASE_2EDGE;

    spi.Init.NSS                = SPI_NSS_SOFT;

    spi.Init.BaudRatePrescaler  = SPI_BAUDRATEPRESCALER_8;

    spi.Init.FirstBit           = SPI_FIRSTBIT_MSB;

    spi.Init.TIMode             = SPI_TIMODE_DISABLED;

    spi.Init.CRCCalculation     = SPI_CRCCALCULATION_DISABLED;

    spi.Init.CRCPolynomial      = 7;

APB2 peripheral clock is configured to 32MHz.

The ADC is the only device connected on SPI1. Electrical signal levels on MISO, MOSI and SPI_CLK verified to be ok using oscilloscope. However, the value seen on the SPI1 MISO on the oscilloscope does not match the value in the SPI1 data register.

Posted on September 09, 2015 at 17:20

What is the GPIOx_OSPEEDR setting of clock pin?

Posted on September 16, 2015 at 15:38

The GPIOx_OSPEEDR for the clock pin is set to high speed. We tried all four speed setings on all SPI1 pins to.