stm32 timed multichannel ADC DMA conversions on STM32F030k6
HTML-код
- Опубликовано: 19 окт 2024
- Yet another "note to future self" video about STM32 DMA ADC acquisition. This time, multiple channels are being sampled into a buffer, triggered by a TIM1 event, rather than by repetitive software calls.
This way, the ADC subsystem does its thing in the background and your code can react when it's ready.
Sorry for the ghastly video and audio production values. I'm not a pro.
Thank you so much for this video! I was using low power modes and was looking for a way to trigger DMA to get ADC values but only once per sec, not in the continuous mode. Just for the sake of lower energy consumption. Couldnt get this on my own, had to enable DMA Continuous requests for it to trigger, such a small detail :/
Thank you so much for the clear and concise explanation.
You're welcome. I hope it was helpful.
Wow...I spent most yesterday trying to figure this one out with no luck...It worked first try after watching this! Thanks man!
You're very welcome!
This is very very helpful. Thank you.
thank you soo much this was super helpful
Dear Rick, Thanks a lot, your video is a clean and pro one, Thanks.
On stm32f103 there is no DMA continious concersion, but circular is enough, but it will not work.
The solution is so easy: swap adc_init and dma_init. DMA must be initialized first in the code.
Thanks, Sohrab! This problem has been seen before. It happened to me too - and took me hours to find the problem! I wish I had known this fix sooner.
can you help me? I use KeilC, DMA is the first, but it dont run continous
Fab overview, one question though, for continuous automatic timer driven ADC DMA transfers of say 32 words a go, using 2 independent ADCs, when the last ADC word is transferred the timer will be generating another DMA request to both ADCs. If the ADC DMA isn't quite finished when the timer event occurs, could there be a problem? I'll test this I guess, only way to find out right? PS I need both ADCs to transfer to the same slot in each buffer at the same time, hence the need for a timer to synchronise the transfers rather than letting the ADCs just run continuously.
Thank you for this tutorial. But I am still wondering about this code HAL_ADC_Start_DMA(&hadc, (uint32_t*)AdcResults, sizeof(AdcResults)/sizeof(AdcResults[0]));
I have used DMA but I did not quite understand the sizeof(...)/Sizeof(...) meaning. i would be grateful help me out.
Hi,
I will try to answer you, it is about what is HAL_ADC_Start_DMA is waiting for and what are you telling with sizeof().
- sizeof(AdcResults): returns size of the array in bytes.
If AdcResults is an array of 3 elements of type uint16_t, the size will be 3* sizeof(uint16_t), which is usually 3* 2 = 6 bytes.
- sizeof(AdcResults) / sizeof(AdcResults[0]): This returns the number of elements in the array. In this case, it will be 6 / 2 = 3 elements. (Adcresults[0] has 2 bytes as it is type uint16_t)
HAL_ADC_Start_DMA is waiting for the number of elements of the array. So if you give it with the first way it may cause malfuctions in your code.
I hope it helped you to figure it out.
@@lookatravieso5036 thank you very much. It is very helpful.
Hi, do you have a public GitHub?