Set up multiple ADCs on STM32 microcontrollers using DMA
HTML-код
- Опубликовано: 25 авг 2024
- Just a little note-to-future-self video, showing how to set up multiple channels on an STM32 ADC, and use scanning to read those ADCs. DMA is set up to record the values to RAM.
This demo uses the STM32CubeIDE development environment, and uses the HAL library, not the LL libs.
Thank you to your past self for taking the time to put this into a video for your future self, and then share it with the rest of us.
Future Self thanks you for your kind comment.
Great Video. I found a bug in the HAL. sometimes (not every time) the generated HAL is wrong. The MX_DMA_Init(); must be called before MX_ADC1_Init(); otherwise the ADC makes just one measurment. But this is not guaranteed always correct. (Cube IDE 1.7.0)
Thank you man!!! almost 1 day debugging and trying to find out why!!!!.. your solution solve it in seconds hehe
Thank you so much, you saved my life on this...
Add another THANKS SO MUCH!!! - I was about to spend several thousand $USD to get someone to fix this because I was at the end of my wits after fighting this for 3+ weeks for a product of ours that we had to redesign to fit in the L433 (from the L476). kokoianer - you are truly apprecaited. I'm going to be reaching out to the local (Austin, TX) ST support team to tell them about this - and I'll give full credit to YOU!
Thank you so much, this really saved me
This can be changed in the Project Manager under Advanced Settings (CubeMX 6.3, probably also in the cubeIDE)! So you don't have to change it manually in the code every time you change something in the cubeMX config.
It is still weird why can be the other way round.
The IDE has slightly changed since this video I think. I had to click the dropdown arrows next to each "Rank" and set them to Channel 1, 2 and 3 respectively. Then the DMA worked fine with the Blackpill F401 board.
This is also a kind of note-to-self thing. Cheers, great vid!
Hi Glowfly! I used a cheap and cheerful F030 in this video, and they don't have the ranking feature. I think the IDE "knows" this and therefore doesn't show the option.
how did you adjust the timers for the adc? on the F401 i cant find an ADC clock
Nice Video. Thanks for uploading
Nice info, thank you for sharing it :)
How many samples per second can be achieved???., Please let me know., i am working on Audio signal
A flawless video
Very kind of you.
You use volatile to tell the compiler the variable is used (updated) outside of the routines that reference it; in this case, the DMA writes to it. You need to change the title of your presentation to Set up multiple channels of a ADC for scan using DMA. This is important because was looking for setting up multiple ADCs (ie. ADC 1, ADC2, ADC3) all using scanning. Since there is only one callback I need to know how to tell which ADC DMA was completed.
Nice overview thanks very much! A question if I may? If someone wants to use two ADCs at the highest speed, but synchronise the readings so that 2 memory buffers receive each sample at the same time, what's the best way in your view? If software start is used they might drift by a sample or two, so use a high speed timer to activate both, one timer drives both? Can a timer run a 1MHz, I guess it can? Or is there a better way?
I got valid reading for only one channel; the other one is always 0. What could be the problem?
You didn't setup multiple ADCs via DMA, rather multiple channels on single ADC. Caption is bit confusing
These are not multiple ADC's but these are multiple channels ADC.
Did you make videos on using ADC1 and ADC2 at the same time
I also would like to use ADC1 and ADC2 at the same time. Did you find any information how to do it? Thanks!
Thank for you jobm it was good
The HAL_ADC_Start_DMA function is consuming a lot of time. Since I am using it in a 50kHz regulator, it is critical to me. Is there another way to start the conversion?
Awesome Video!!
Could you post the code in the description?
It looks like this example does 1 reading for each of the 3 adc channels. How do you do multiple adc readings for each channel?
I also would like to use ADC1 and ADC2 at the same time. Did you find any information how to do it? Thanks!
@@yogaline8218 basically repeat the same settings in as the first ADC in whichever ADC you're going to use in cubemx then call the hal functions twice with the two adc pointers (&hadc1, &hadc2)
Did the same, works flawless for 3 out of 5 channels I used...
Doesn't seem to be the wiring, "adcResultsDMA" is consistently wrong on index 2 and 3, even if I use different channels in board config
You probably got the RANK out of order then...
awesome video. How can i do this with a timer?
Thanks!
You can trigger ADC conversions with an "event", and set up the timer to issues those events. I've got a video about it: ruclips.net/video/Q4I9m0kNZBI/видео.html
thx
the ending gave me schizophrenia