Skip to main content
Associate III
July 23, 2025
Question

DMA Issue in NUCLEO-H753ZI board.

  • July 23, 2025
  • 2 replies
  • 600 views

Hi,

I am using NUCLEO-H753ZI board. My ZIPPED project is attached.

ADC1 Rank 1 Channel 10 Rank 2 Channel 5

ADC2 Rank 1 Channel 10 Rank 2 Channel 15

ADC3 Rank 1 Channel 10 Rank 2 Channel 2

Channel 10's input: Positive side of 1.5VDC battery, whose negative side is connected to GND of the board.

All other channels are connected to one side of 0.8VAC sine wave signal, whose other side is connected to the positive side of the above .5VDC battery.

The three arrays are defined for ADC1, ADC2 and ADC3 in below:

static uint16_t adc_value1[NUM_SCANS * NUM_RANKS] __attribute__((aligned(32)));

static uint16_t adc_value2[NUM_SCANS * NUM_RANKS] __attribute__((aligned(32)));

static uint16_t adc_value3[NUM_SCANS * NUM_RANKS] __attribute__((aligned(32)));

Three flags are set up for DMA completion in void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)

Problem: in DEBUG Mode,, when DMA is completed, the data in the above arrays is inconsistent with the data in the dump output window "Details:{1116,...". Look like DMA process in my code is not handled properly. My ZIPPED project is attached.

I tried to add InvalidateADCBufferCache unsuccessfully - running into HardFault.

I also try to run in RAM_D2 instead of RAM_D1 unsuccessfully.

My ZIPPED project is attached.

Thank you very much for your help,

 

Peter

2 replies

TDK
Super User
July 23, 2025

> the data in the above arrays is inconsistent with the data in the dump output window "Details:{1116,..."

What is the data in the above arrays?

What is the data in the dump output window?

In what way is it inconsistent?

"If you feel a post has answered your question, please click ""Accept as Solution""."
Associate III
July 23, 2025

It is sampled data in ADC1, ADC2, ADC3 based on their input signals (See the posted) stored in 

static uint16_t adc_value1[NUM_SCANS * NUM_RANKS] __attribute__((aligned(32)));

static uint16_t adc_value2[NUM_SCANS * NUM_RANKS] __attribute__((aligned(32)));

static uint16_t adc_value3[NUM_SCANS * NUM_RANKS] __attribute__((aligned(32)));

In Watch Window, we can see every elements in the above arrays with its array index.

When highlight one of the arrays, we can see the array's data "Details:{1116,.1120........}" in series. 

It should match each element in the array. But there is no match. 

Look like DMA process in my code is not handled properly. My ZIPPED project is attached.

I tried to add InvalidateADCBufferCache unsuccessfully - running into HardFault.

I also try to run in RAM_D2 instead of RAM_D1 unsuccessfully.

My ZIPPED project is attached.

Thank you very much for your help,

 

 

TDK
Super User
July 23, 2025

DMA constantly updates values even when the chip is paused, if configured to do so. Depending on how/when the debugger reads them, they may show up differently in different regions. This is not an issue, the values are correct at the time at which the debugger reads them.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Tesla DeLorean
Guru
July 23, 2025

>>I tried to add InvalidateADCBufferCache unsuccessfully - running into HardFault.

Look at what's actually faulting, and what memory you're invalidating. DMA itself shouldn't cause execution faults, just data coherency issues.

Also Invalidating discards data in the cache and write-buffers, use VERY carefully to avoid collateral damage in abutting structures.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Associate III
July 23, 2025

I am not using  InvalidateADCBufferCache.

You have to check my code to find the problem.

Thanks,

Tesla DeLorean
Guru
July 24, 2025

>>You have to check my code to find the problem.

Yeah, I'm not that invested, perhaps work with your colleagues or supervisor that has some responsibility for your project.

If it Hard Faults, like you've described, run that to ground as it might give you some insight

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..