cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G4 DAC DMA double data

Repwoc
Associate II

I can produce a sine wave using DAC1 + DMA on a STMG431CBU6 MCU, but I'd like to increase the frequency (purely as a learning exercise).  In the application note https://www.st.com/resource/en/application_note/an4566-extending-the-dac-performance-of-stm32-microcontrollers-stmicroelectronics.pdf it suggests that the DAC update rate can be increased by using DMA Double Data mode.  When I enable double data mode in STM32CubeIde, however, the generated sine wave frequency is halved and an additional high frequency signal is superimposed on it.

DAC settings (DMA double data enabled):

Repwoc_3-1731767996200.png

Sine wave generated when DMA double data is disabled:

Repwoc_0-1731767007247.png

Sine wave generated when DMA double data is enabled:

Repwoc_1-1731767107930.png

'Close-up' of the superimposed signal:

Repwoc_2-1731767190091.png

From this image the superimposed signal frequency seems to be ~6.17 MHz.

I presume there is more to enabling DMA double data mode than changing the DAC setting in STM32CubeIDE, but I haven't been able to find anything else.  Can anyone tell me where I have gone wrong or what else I need to do?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Repwoc
Associate II

Never mind - I figured it out.

With DMA double data enabled it is also necessary to set the DMA data width to Word for both peripheral and memory and to pack the wave sample data into 32 bit values, with two samples in each 32 bit value.  So the wave data array is half as large as it was (in terms of number of elements).  The array length parameter of HAL_DAC_Start_DMA() must be altered to suit.

View solution in original post

1 REPLY 1
Repwoc
Associate II

Never mind - I figured it out.

With DMA double data enabled it is also necessary to set the DMA data width to Word for both peripheral and memory and to pack the wave sample data into 32 bit values, with two samples in each 32 bit value.  So the wave data array is half as large as it was (in terms of number of elements).  The array length parameter of HAL_DAC_Start_DMA() must be altered to suit.