cancel
Showing results for 
Search instead for 
Did you mean: 

DMA double buffer with STM32CubeMX

sdim
Associate III
Posted on November 09, 2014 at 23:37

I want to use DMA with double buffer. STM32CubeMX provides options for normal and circular buffer. 

Should I select circular buffer and then modify the source or is it better to wait for the next version of STM32CubeMX, hoping that there will be a ''double buffer'' option on the next version?
4 REPLIES 4
stm32cube-t
Senior III
Posted on November 13, 2014 at 16:42

Hello,

The double buffer mode is not covered by HAL_DMA_Init function. So there is no STM32CubeMX update to expect for this.

However, the double buffer mode can be enabled using either one of the functions:

HAL_DMAEx_MultiBufferStart

or

HAL_DMAEx_MultiBufferStart_IT

.

Best Regards

sdim
Associate III
Posted on December 08, 2014 at 00:40

Thanks for the answer.

How can I use HAL_DMAEx_MultiBufferStart_IT ?

The information on the HAL driver description helpful but not very detailed on how to use it.

Should I use it after HAL_UART_Transmit_DMA or should I replace HAL_DMA_Start_IT inside HAL_UART_Transmit_DMA with HAL_DMAEx_MultiBufferStart_IT ?

ccox
Associate II
Posted on March 10, 2015 at 16:05

For the benefit of others, it appears that Stavros' second idea is correct. In order to get double-buffering to work for an SPI port, I had to create a modified version of HAL_SPI_Transmit_DMA() that calls HAL_DMAEx_MultiBufferStart_IT() instead of HAL_DMA_Start_IT().

ccox
Associate II
Posted on March 13, 2015 at 19:23

You will also need to create a Memory1 transfer complete callback function (e.g. HAL_SPI_TxM1CpltCallback()) and set the XferM1CpltCallback pointer to point to it.