Skip to main content
snjy1697
Associate II
December 14, 2019
Solved

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

  • December 14, 2019
  • 3 replies
  • 1907 views

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.

This topic has been closed for replies.
Best answer by snjy1697

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().

3 replies

snjy1697
snjy1697Author
Associate II
December 16, 2019

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.

waclawek.jan
Super User
December 16, 2019

I don't use Cube/CubeMX.

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

JW

snjy1697
snjy1697AuthorBest answer
Associate II
December 17, 2019

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().