cancel
Showing results for 
Search instead for 
Did you mean: 

DMA Issue in NUCLEO-H753ZI board.

RongShengWang
Associate III

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

14 REPLIES 14
TDK
Super User

> 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".

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,

 

 

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".

Your comment does not help at all.

If you don't want me in this thread, I will leave. Cheers.

Are you the OP? One user two accounts?

If you feel a post has answered your question, please click "Accept as Solution".

>>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 Venmo
Up vote any posts that you find helpful, it shows what's working..

See also repasting materially the same information over again, and highlighting.

Also probably not a large audience is going to want to dig thru all the code. Perhaps simplify, doing ONE ADC

Add instrumentation and diagnostic output so the debugger interferes less and you can see what's happening, and cause of faults.

The ADC_Completion_Flag needs to be volatile.

No real space/speed value to using 8-bit and 16-bit variables on a 32-bit MCU, so would avoid that where possible.

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

I am not using  InvalidateADCBufferCache.

You have to check my code to find the problem.

Thanks,

You have to check my code to find the problem.

Thanks,