Skip to main content
Richy
Visitor II
September 14, 2018
Question

Bug in STM32F0 SPI Low-Level Driver LL_SPI_ReceiveData8 and LL_SPI_TransmitData8

  • September 14, 2018
  • 1 reply
  • 1056 views

Affected driver library STM32Cube_FW_F0_V1.9.0

Component SPI Low Level Driver in file "stm32f0xx_ll_spi.h"

Functions affected: LL_SPI_ReceiveData8 and LL_SPI_TransmitData8

Bug:

current implemented acces to SPIx->DR doesn't work as expected due to FIFO which resides in the STM32F0. Accessing the DR register with data wider than 8 Bit fills the FIFO and generates multiple physical reads / writes on the spi bus.

Correct implementation: cast DR register to 8 Bit.

__STATIC_INLINE void LL_SPI_TransmitData8(SPI_TypeDef *SPIx, uint8_t TxData)

{

 *((__IO uint8_t *)&SPIx->DR) = TxData;

}

__STATIC_INLINE uint8_t LL_SPI_ReceiveData8(SPI_TypeDef *SPIx)

{

 return (uint8_t)(READ_REG(SPIx->DR));

}

Possibly LL_SPI_ReceiveData16 / LL_SPI_TransmitData16 are affected too. Have not tested this.

HAL implementation on the other hand is correct

This topic has been closed for replies.

1 reply

ST Technical Moderator
September 14, 2018

Hello @Richy​ ,

Thank you for sharing this issue. We will check it internally and come back to you as soon as possible.

With Regards,

Imen.

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks