cancel
Showing results for 
Search instead for 
Did you mean: 

Why is the ADC w/DMA in STM32G4 not working?

snjy1697
Associate II

I am initialising the ADC2 w/DMA via STM32CubeMX.

Scan conv. = enabled

continuous conv. = enabled

DMA cont. requests = enabled

overrun behaviour = data preserved

number of conversions = 2 (channel 1 and channel 2)

sequence of program (specific to DMA):

1 - uint32_t adc_val[2] (variable created for DMA)

2 - MX_DMA_init

3 - HAL_ADC_Start_DMA_ (passed adc_val)

4 - while(1) (using UART to send the adc data)

I tried the same program using adc polling (HAL_ADC_getvalue) and it did give me some data. But the DMA doesnt seem to work.

1 ACCEPTED SOLUTION

Accepted Solutions
snjy1697
Associate II

https://community.st.com/s/question/0D50X0000BVnBhASQV/bug-report-dma-and-adc-initialization-order-changed-in-stm32f4-hal-v1241-causing-incorrect-adc-operation

thanks @Community member​ for mentioning all the possible reasons for the issue.

I found the link pasted above to be the exact solution for the problem that i am facing. I had to change the order of DMA_init() and place it before ADC_init().

View solution in original post

4 REPLIES 4

i tried shifting the DMA_init function above the ADC_init function. But that didnt help. I am still trying to look further into the different questions mentioned in your link.

I don't use Cube/CubeMX.

I'd read out and check content of respective ADC, DMAMUX and DMA registers.

JW

snjy1697
Associate II

https://community.st.com/s/question/0D50X0000BVnBhASQV/bug-report-dma-and-adc-initialization-order-changed-in-stm32f4-hal-v1241-causing-incorrect-adc-operation

thanks @Community member​ for mentioning all the possible reasons for the issue.

I found the link pasted above to be the exact solution for the problem that i am facing. I had to change the order of DMA_init() and place it before ADC_init().