2023-02-23 12:24 AM
On my STM32F030, I need to read analog values from three channels of the ADC1. These readings need to be periodical and I am using the TIM3 interrupt to trig the ADC value capture. When do not using DMA and collecting only one ADC channel value, everything works fine. As I need the three channels, I have to use DMA and once I activate this, I properly get a first value of the three channels but the ADC interrupt is never triggered any more and no new data are collected.
Any advice about this ?
Thanks
2023-02-23 12:35 AM
>>TIM3 interrupt to trig the ADC value capture,
the interrupt doesnt need to be activated, just select the TIM update event .
But i dont think thats the cause of your problem
Similar question i had some time ago: https://community.st.com/s/question/0D53W00001AOJx3SAH/stm32f207-dmaadc-captures-only-one-channel-only-once
2023-02-23 12:38 AM
Thanks for answer but the problem onmy appears when DMA is used. In this case, even if TIM Update event is enable, I do not get periodic ADC capture. I only get once at startup of the uC
And if DMA is not used, everything works properly (on a single channel)
2023-02-23 01:23 AM
Thanks for the link to Digikey. Actually, I needed to enable DMA continuous request. Not sure this means that DMA values are updated at the TIM3 interrupt rate (I have to investigate power consumption). In the Digikey example they also enabled continuous conversion mode which is not wanted in my application.
Thanks for your support.
2023-02-23 01:26 AM
DMA continuous request: https://electronics.stackexchange.com/questions/500827/dma-continuous-request-functionality
>>this means that DMA values are updated at the TIM3 interrupt rate (I have to investigate power consumption).
I believe how this works is TIM triggers ADC triggers DMA, so effectively yes, DMa transfer will be triggered every TIM event
>>the Digikey example they also enabled continuous conversion mode which is not wanted in my application.
Thats fine, you got the basics there, if you choose normal conversion and you trigger them very frecuently ,have in mind, you could be starting a new conversion to soon and the last one didnt finished. DMa doesnt like this.
2023-02-23 01:34 AM
In my case, this is every second so I assume there is no such issue :)
As soon as I will inspect power consumption, I will keep you informed about the actual behaviour of who is trigerring who :)
Thanks again
2023-02-23 02:10 AM
There is maybe one indication that he triggering of the ADC is maybe not only once due to TIM3 interrupt.
I have only three channels to convert.
In the code, I use HAL_ADC_Start_DMA(&hadc, value, 9) with 9 memory locations instead of 3 (which is the mandatory quantity)
In Debug mode, I stop at each TIM3 interrupt and I look at the "value" variable content and there are more than 3 elements which are updated. This means that the ADC makes more than one sequence of channel conversion... so from power consumption point of view, this would be not optimal. Evenmore as I do not know if the ADC and DMA are not running continuously...
OR maybe the amount in the HAL_ADC_Start_DMA call is driving the ADC behaviour and after 9 steps it stops ADC conversion...
Not clear for me.
2023-02-23 02:41 AM
Read out and check the TIM, ADC and DMA regiseters' content.
If you've clicked the code in CubeMX, it may be the "incorrect DMA initialization order in CubeMX" problem. Search in this forum.
JW