AnsweredAssumed Answered

Bug: STM32CubeF1 V1.2.0 HAL_SPI_Receive_DMA()

Question asked by brunner.alexander on Aug 21, 2015
Latest reply on Feb 22, 2017 by sidlauskas.david
Hello all,

When using the STM32CUBEF1 V1.2.0 HAL-library with SPI and DMA transfer just for receiving data, I came across unusual behaviour.
An investigation showed, that the function HAL_SPI_Receive_DMA() sets the callback functions of the transmit DMA handle to 0. When not using a DMA for TX at all, the handle hdma is already 0, leading to dereferencing a nullpointer and causing a hard fault.

/* Reset content of SPI TxDMA descriptor */
hspi->hdmatx->XferHalfCpltCallback = 0;
hspi->hdmatx->XferCpltCallback     = 0;
hspi->hdmatx->XferErrorCallback    = 0;

The same applies to the function HAL_SPI_Transmit_DMA().

/* Reset content of SPI RxDMA descriptor */
hspi->hdmarx->XferHalfCpltCallback = 0;
hspi->hdmarx->XferCpltCallback     = 0;
hspi->hdmarx->XferErrorCallback    = 0;

The file in question  is \STM32Cube_FW_F1_V1.2.0\Drivers\STM32F1xx_HAL_Driver\Src\stm32f1xx_hal_spi.c

Maybe this issue could be resolved for the next release of the software.

Regards,
Alex

Outcomes