Skip to main content
Associate II
Oct 7, 2025 10:01 AM UTC
Solved

STM32G431C + ADC + DMA

I'm using ADC with DMA in a large project, and faced some very strange problem: 

If I'm using DMA2 Channel 6 - ADC works correctly 

If I'm using DMA2 Channel 1 - the SW end up in Hard Fault 

Screenshot 2025-10-07 125752.pngScreenshot 2025-10-07 125821.pngScreenshot 2025-10-07 124405.png

The configuration is default. 

This is how I start the conversation 

 HAL_ADCEx_Calibration_Start(&hadc1, ADC_SINGLE_ENDED);
 // Start the ADC in DMA mode
 HAL_ADC_Start_DMA(&hadc1, (uint32_t*) g_ADC_values, ADC_BUFFER_LENGTH);
KDJEM.1
KDJEM.1Best answer
ST Technical Moderator
Oct 8, 2025 11:07 AM UTC

Hello @AChas.1 ;

 

I recommend you to look at How to debug a HardFault on an Arm® Cortex®-M STM32  - STMicroelectronics Community article may help you to debug faults on Arm Cortex®-M based STM32 devices.

 

I hope this help you.

Thank you.

Kaouthar

To give better visibility on the answered topics, please click on "Best answer" on the reply which solved your issue or answered your question.

6 replies

TDK
Oct 7, 2025 1:55 PM UTC

What is the stack trace when the hard fault happens? What code is causing it to hard fault?

"If you feel a post has answered your question, please click ""Accept as Solution""."
AChas.1Author
Associate II
Oct 7, 2025 3:55 PM UTC

The random code, it depends when ADC triggers the DMA 

TDK
Oct 7, 2025 5:29 PM UTC

I can't make sense of this answer.

Using DMA doesn't cause a hard fault in itself. It's possible the DMA is misconfigured, or trying to write somewhere it cannot. Look for the reason it's hard faulting and go from there.

"If you feel a post has answered your question, please click ""Accept as Solution""."
KDJEM.1
KDJEM.1Best answer
ST Technical Moderator
Oct 8, 2025 11:07 AM UTC

Hello @AChas.1 ;

 

I recommend you to look at How to debug a HardFault on an Arm® Cortex®-M STM32  - STMicroelectronics Community article may help you to debug faults on Arm Cortex®-M based STM32 devices.

 

I hope this help you.

Thank you.

Kaouthar

To give better visibility on the answered topics, please click on "Best answer" on the reply which solved your issue or answered your question.
AChas.1Author
Associate II
Jan 23, 2026 8:04 AM UTC

Long story short, I can't avoid this problem but I'm almost shure it was coz of RAM tension I've got in my firmware. I lose my patience and just switch to STM32G491 - now it works like a charm :)