Skip to main content
david.rojas
Associate
July 12, 2020
Solved

STM32G474 signal generation with DMA + DAC using STM32CubeMX HAL

  • July 12, 2020
  • 2 replies
  • 2519 views

I am trying to generate a periodic signal with the DAC on the STM32G474 using DMA. There are tons of examples of this, and I´ve done the same in the past with an STM32L4 and F4 with no issues. However, I´m not sure if there is a problem in the STM32G4 line or a bug in the libraries/HAL code generation. I set up a simple example, just with a circular buffer of 2 samples at a slow rate, but I never get anything out, it generates on start a DMA transfer error and disables DMA.

I have tried different pins and channels. In the STM32G4, the DMA streams are multiplexed so you can use any as long as you are not using the same for other peripherals. I tried starting the timer first, including delays, calling HAL_DAC_Start() before HAL_DAC_Start_DMA() (which is redundant). Setting a value manually to the DAC works with no problem. I have tried also using Timer2. I´m using STM32CubeIDE 1.3.1 and the code is generated with STM32CubeMX 5.6.1, the latest versions.

The main.c is here, it includes all configuration: https://pastebin.com/F90s3iBz

This topic has been closed for replies.
Best answer by david.rojas

I found the issue: the difference between the STM32G4 and the previous families with respect to DMA is that the data width for the Peripheral has to be set as Word always, even though the data width for the Memory is set to Half Word.

2 replies

david.rojas
david.rojasAuthorBest answer
Associate
July 12, 2020

I found the issue: the difference between the STM32G4 and the previous families with respect to DMA is that the data width for the Peripheral has to be set as Word always, even though the data width for the Memory is set to Half Word.

JHari.1
Associate II
January 18, 2022

I have a similar issue and changing the dma word transfer size didnt help. Any tips on how to get the DAC to work?