AnsweredAssumed Answered

A Bug With STM32Cube FW_F4 V1.11.0 Firmware on SPI module

Question asked by jiasu.mi on May 6, 2016
Latest reply on May 6, 2016 by Nesrine M

I have upgraded from STM32Cube FW_F4 V1.10.0 to V1.11.0 and the SPI part doesn't work well. When sending only one byte at a very low speed with softwase NSS, the HAL_SPI_TransmitReceive() function will return before the byte has ben transmitted and thus leads to the following program release the CS Pin in my code.

I read the code of V1.11.0 and I found at line 919:
if((hspi->RxXferCount > 0U) && (__HAL_SPI_GET_FLAG(hspi, SPI_FLAG_RXNE)))

Because of C language's Lazy Evaluation, when hspi->RxXferCount has reached zero, it won't check SPI_FLAG_RXNE flag and the function will return at once. I think the order of to conditions should be changed.