cancel
Showing results for 
Search instead for 
Did you mean: 

Bug in Low-Level driver LL_SPI_ReceiveData8 for STM32L0, STM32L4, STM32L5 and possibly others

SOfne.1
Associate III

Affected driver libraries: STM32Cube_FW_L5_V1.4.0, STM32Cube_FW_L4_V1.16.0, STM32Cube_FW_L0_V1.11.2 and possibly other device driver libraries based on the same SPI peripheral

File: stm32yyxx_ll_spi.h (Replace yy by L5, L4, F0, ...)

Functions affected: LL_SPI_ReceiveData8

Bug: Current implementation performs a 16bit read access to DR register and then casts the result to 8 bits. This leads to unexpected behavior. For example STM32L5 supports data packing, when SPI data frame size is less than or equal to 8 bits and 16 bits are read. In this case, the current implementation of LL_SPI_ReceiveData8 reads two (packed) bytes from DR register and discards the second one when casting the read result to 8 bits.

Correct implementation: Cast pointer to DR register to uint8_t before access.

__STATIC_INLINE uint8_t LL_SPI_ReceiveData8(SPI_TypeDef *SPIx)

{

  return *((__IO uint8_t *)&SPIx->DR)

}

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Imen DAHMEN​ 

Thank you.

As you can see in the corresponding git repository for STM32CubeF0 firmware package this issue is still present in STM32CubeF0 V1.11.2.

Best regards,

Sebastian

View solution in original post

6 REPLIES 6
Imen.D
ST Employee

Hello @SOfne.1​  and welcome to the STM32 Community :)

Thanks for pointing out this issue.

I am checking it internally and I will come back to you with details about corrective actions we will take, or explanation if needed.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

​Hi @SOfne.1​ ,

This issue will be fixed in the coming release of STM32CubeL5 MCU package.

Thanks for your contribution.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

Hi @Imen DAHMEN​ 

Thanks for your fast response. Will this issue be fixed in the next releases of STM32CubeF0 and STM32CubeL4 MCU package, too?

Best regards,

Sebastian

Hi @SOfne.1​ ,

I think this is already fixed in the release of STM32CubeF0 V1.11.0.

I reported this issue internally to check and fix all impacted series.

Thanks for your feedback.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

Hi @Imen DAHMEN​ 

Thank you.

As you can see in the corresponding git repository for STM32CubeF0 firmware package this issue is still present in STM32CubeF0 V1.11.2.

Best regards,

Sebastian

Imen.D
ST Employee

Hi @SOfne.1​,

You are right, only LL_SPI_TransmitData8() is correct in the latest CubeF0. I've escalated this issue to correct LL_SPI_ReceiveData8() API.

The same correction will be performed for all impacted series.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen