2024-11-16 06:43 AM
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):
Sine wave generated when DMA double data is disabled:
Sine wave generated when DMA double data is enabled:
'Close-up' of the superimposed signal:
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?
Solved! Go to Solution.
2024-11-16 08:31 AM
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.
2024-11-16 08:31 AM
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.