cancel
Showing results for 
Search instead for 
Did you mean: 

How to read the current DMA buffer pointer correctly?

MMoha.3
Associate III

Hello,

I'm using an stm32f429zit6's ADC in triple interleaved DMA mode. They're giving me 7.2 Msps currently.

The ADC is continuously running in circular mode and filling a buffer with a size of 3000.

So I wanted to find out the DMA buffer pointer when a trigger happens to later order the data before and after the trigger event properly.

I realize that the NDTR register in the DMA2Stream0 stores the required data for me, So to verify that I used the following lines in the ADC conversion complete callback function,

and expected to see 0 (or 2999 which is the buffer maximum length) for the Buffer_Addr_At_Trigger variable in the debug mode.

But it didn't give me a consistent value for the variable and instead I get some random value between 0 to 2999 from the register each time the debugger gets to the breakpoint.

What can be the issue?

void HAL_ADC_ConvCpltCallback (ADC_HandleTypeDef* hadc1) {
    Buffer_Addr_At_Trigger = hdma_adc1.Instance->NDTR;
}

3 REPLIES 3

> But it didn't give me a consistent value for the variable and instead I get some random value between 0 to 2999 from the register

> each time the debugger gets to the breakpoint.

> What can be the issue?

> The ADC is continuously running in circular mode

JW

PLess.1
Associate

Did you manage to solve this?

I do not quite remember the issue at this moment,

But at the time I was working on this project:

https://github.com/mmahdim/stm32f4scope

It is now working and only needs a bit of code cleanup.