2021-06-16 06:15 AM
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);
}
}
2021-06-16 07:08 AM
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
2021-06-17 10:42 PM
Q- Which STM32?
ANS- STM32H7B0VBT6
THANK YOU
2021-06-17 10:49 PM
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.
2021-06-18 12:42 AM
Read out and check content of ADC2 and the common registers.
JW
2021-06-18 06:44 AM
Okay i will check.