SPI Master receive DMA always go to HAL_SPI_ErrorCallback() on STM32F407-disco
- October 21, 2021
- 3 replies
- 4256 views
I am struggling on SPI Master receive on STM32F407-disco board.
I plan to interface to the microphone using SPI2 master receive.
I setup the DMA but I always get to HAL_SPI_ErrorCallback().
I setup the same setup using Nucleo-G474 but it can go to HAL_SPI_RxCpltCallback().
I used the same codes for both G474 and F407.
HAL_SPI_Receive_DMA(&hspi2, receive_data, 5);
void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi)
{
printf("SPI Received! \n");
}
void HAL_SPI_ErrorCallback(SPI_HandleTypeDef *hspi)
{
printf("TRANSFER_ERROR! \n");
}I am using CubeMX to setup F407 as shown below.
F407 parameter setting
F407 DMA setting
I used the same on G474 as shown below.
G474 parameter setting
G474 DMA setting
Basically everything is almost the same.
When debug, I checked the before and after HAL_SPI_Receive_DMA() of both SPI and DMA register data as shown below.
G474 DMA1 before HAL_SPI_Receive_DMA()
G474 DMA1 after HAL_SPI_Receive_DMA()
G474 SPI2 before HAL_SPI_Receive_DMA()
G474 SPI2 after HAL_SPI_Receive_DMA()
F407 DMA1 before HAL_SPI_Receive_DMA()
F407 DMA1 after HAL_SPI_Receive_DMA()
Any idea what did I miss? I am using CubeIDE 1.7.0 and STM32Cube_FW_F4_V1.26.2 and STM32Cube_FW_G4_V1.4.0.
Here are the IOC files for both devices.