AnsweredAssumed Answered

Bug in STM32L4xx_HAL_Driver, QUADSPI

Question asked by d_ascenzio.julien on May 4, 2018
Latest reply on May 4, 2018 by Amel N

Hi,

I found a bug in the quad spi driver for stm32l4xx. In the function  HAL_QSPI_Receive_IT, the interrupts flags must be cleared before start transfer otherwise flag TC could be missed:

- WRITE_REG(hqspi->Instance->AR, addr_reg) -> transfer start
- An other task r or interrupt run...
- The transfer qspi finish, flag TC set
- __HAL_QSPI_CLEAR_FLAG(hqspi, QSPI_FLAG_TE | QSPI_FLAG_TC) -> the flag TC is cleared !BUG!

 

My patch:

 

--- a/library/STM32Cube_FW_L4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_qspi.c
+++ b/library/STM32Cube_FW_L4/Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_qspi.c
@@ -1098,12 +1098,12 @@ HAL_StatusTypeDef HAL_QSPI_Receive_IT(QSPI_HandleTypeDef *hqspi, uint8_t *pData)
       /* Configure QSPI: CCR register with functional as indirect read */
       MODIFY_REG(hqspi->Instance->CCR, QUADSPI_CCR_FMODE, QSPI_FUNCTIONAL_MODE_INDIRECT_READ);
 
-      /* Start the transfer by re-writing the address in AR register */
-      WRITE_REG(hqspi->Instance->AR, addr_reg);
-
       /* Clear interrupt */
       __HAL_QSPI_CLEAR_FLAG(hqspi, QSPI_FLAG_TE | QSPI_FLAG_TC);
 
+      /* Start the transfer by re-writing the address in AR register */
+      WRITE_REG(hqspi->Instance->AR, addr_reg);
+
       /* Process unlocked */
       __HAL_UNLOCK(hqspi);

Outcomes