AnsweredAssumed Answered

HardFault during HAL_SPI_Receive_DMA()

Question asked by ChiaSyan on Nov 29, 2015
Hi, just a quick note:

HAL library: F2 v1.1.0 (09/Oct/2015) 

I was trying to use this function and have encountered hardfault when the size is >1.
I did not look deep into the problem, but the cause seems to be on the line 16 (code below).
Notice that the HAL_SPI_TransmitReceive_DMA() function is called using repeated "pData".

Workaround is to use HAL_SPI_TransmitReceive_DMA() directly in application, using separate buffers.
If anyone has some insight or explanation to this issue, please provide here. Thank you :)

01.HAL_StatusTypeDef HAL_SPI_Receive_DMA(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size)
02.{
03.    ......
04. 
05.    /* Configure communication direction : 1Line */
06.    if(hspi->Init.Direction == SPI_DIRECTION_1LINE)
07.    {
08.       SPI_1LINE_RX(hspi);
09.    }
10.    else if((hspi->Init.Direction == SPI_DIRECTION_2LINES)&&(hspi->Init.Mode == SPI_MODE_MASTER))
11.    {
12.       /* Process Unlocked */
13.       __HAL_UNLOCK(hspi);
14. 
15.       /* Call transmit-receive function to send Dummy data on Tx line and generate clock on CLK line */
16.       return HAL_SPI_TransmitReceive_DMA(hspi, pData, pData, Size);
17.    }
18. 
19.    ......
20.}

Outcomes