AnsweredAssumed Answered

STM32F103RB SPI TX DMA transfer complete check ?

Question asked by horbach.markus on Jul 21, 2016
Latest reply on Jul 22, 2016 by horbach.markus

Hello everyone

with an STM32F103RB and an ILI9341 TFT i am accelerating my Firmware with DMA functionality. With DMA, I get a huge boost in Performance but I am missing some Infos how to use DMA correctly. With MEM2MEM DMA and the HAL Drivers i can start an MEM2MEM DMA and poll the end of the DMA Transfer like this:

HAL_DMA_Start( ... );

HAL_DMA_PollForTransfer( ... );

Using SPI TX DMA works also ( with great Performance boost, up to 6 times faster Screen refresh):

HAL_SPI_Transmit_DMA( ... );

But I do not know how to determine if the SPI TX DMA transfer is finished. The STM32F103RB can prepare new data to send faster than the DMA Transfer takes time, so I have to wait for the next SPI DMA Transfer. Now, im am using a delay to ensure that the SPI DMA Transfer has finished but this is not reliable, because it depends on the calculating time of the CPU and the amount of transferred data. UM1850 offers no function like for MEM2MEM DMA to determine the end of an SPI TX DMA Transfer. AN4931 brought some Infos, but no solution. Register NDTR should be checked, but DMA1->... gives no auto complete for this Register (I am using Keil5+ CubeMX 4.14). Also enabling the IRQ for SPI DMA in CubeMX and adding a control variable into the IRQ Routine "void DMA1_Channel5_IRQHandler(void)" which i can check did not work. The IRQ Handler is started, i checked it with printf on SWO. How do I check the end of an SPI TX DMA Transfer in the CubeMX way ?

Thanks for your suggestions,

Markus.

Outcomes