Problems with SPI DMA transfer on STM32H743
Hello community,
I am facing massive problems using the SPI1 with DMA transfer on the STM32H743 Nucleo board. Using interrupt based transfer works, but when I try to use DMA I always receive zeros in the receive buffer and I get an overrun error from the SPI peripheral.
As the SPI is configured in full duplex master mode I use the HAL_SPI_TransmitReceive_DMA function to generate a clock signal on the bus when I want to receive data. I configured both TX and RX DMA channels for the SPI. HAL_SPI_TransmitReceive_DMA returns HAL_OK. DMA transfer is completed and SPI_DMATransmitReceiveCplt is called. However, HAL_SPI_TxRxCpltCallback is not called due to the overrun error of the SPI.
I know that there are several rules to obey when you want to use DMA with the STM32H743. The DMA channels can only access RAM in the D1 and D2 region. As I use TrueStudio with the gnuarm compiler I added following section to the linker file:
.DMA_**** :
{
. = ABSOLUTE(0x30047000);
*(.DMA_*****);
} >RAM_D2I initialized the buffers in the source code in the following way:
__attribute__((section(".DMA_****"))) RFM22_RX_BUFFER_t RFM22_RX_buffer;
__attribute__((section(".DMA_****"))) uint8_t dump[RX_READ_BYTES];
__attribute__((section(".DMA_****"))) uint8_t dump2[RX_READ_BYTES];I verified with the debugger, that the buffer variables are in the correct RAM section.
I also know that using the D-cache can lead to several problems. I configured the memory protection unit in a way that the Buffer section is not cacheable not shareable and not bufferable. I even tried it with cache complete deactivated. But I still get the same erroneous behaviour.
Does anyone have a hint whether I might have missed something important?
Best regards,
Daniel
