AnsweredAssumed Answered

Problem when using SPI1 controller on the STM32L053C8

Question asked by johansson.per on Sep 9, 2015
Latest reply on Sep 16, 2015 by johansson.per

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

Setup:

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.

 

 

Problem:

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).

</p>

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

</span>

 

 

</p>

 

</span>

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

 

Questions:

- 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.

Outcomes