cancel
Showing results for 
Search instead for 
Did you mean: 

How to excess DMA_SxNDTR register

NKann.1
Associate III

I am trying to collect data from ADC using DMA in circular buffer mode.

i want to excess/read DMA_SxNDTR register. also tell me how to read data from circular buffer. I have written code for reading count from DMA_SxNDTR but it is not working , it is going to "void HardFault_Handler(void)" and stop there.i have attached screenshot.

code is-

uint32_t ADC1_value[TSN_2]={0};

uint16_t ADC1_value1[TSN]={0};

uint32_t * ADC_array_value = ADC1_value;

uint16_t * DMA_count;

int main(void)

{

DMA_count = (uint16_t *)0x40020014; //assigning address of DMA_SxNDTR

HAL_ADCEx_MultiModeStart_DMA(&hadc1, &ADC1_value[0], NN);

 HAL_Delay(1000);

 k = * DMA_count + 100; // this statement is not executed successfully(going in to error mode)

 for(n=0;n<NN;n++)

 {

ADC1_value1[n] = * (ADC_array_value + n + k);

 }

}

0693W00000Bb9ZrQAJ.jpg

5 REPLIES 5

Which STM32?

> uint16_t * DMA_count;

Note, that usually DMA registers can be accessed only as 32-bits.

Normally, you would read the NDTR's value by

k = DMA1_Stream0->NDTR;

JW

NKann.1
Associate III

Q- Which STM32?

ANS- STM32H7B0VBT6

THANK YOU

NKann.1
Associate III

I am trying to use both adc ( ADC1 and ADC2 ) in duel mode with DMA in circular mode. ADC value should be stored in ADC_DR register. ADC1 is working fine but ADC2 is not working , it is showing zero value in ADC_DR register. where am i doing mistake . Please help.

Read out and check content of ADC2 and the common registers.

JW

Okay i will check.