Set up multiple ADCs on STM32 microcontrollers using DMA

Поделиться
HTML-код
  • Опубликовано: 3 фев 2025

Комментарии • 41

  • @markday3145
    @markday3145 2 года назад +5

    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.

    • @randomrickUK
      @randomrickUK  2 года назад +3

      Future Self thanks you for your kind comment.

  • @glowfly
    @glowfly 2 года назад +4

    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!

    • @randomrickUK
      @randomrickUK  2 года назад +1

      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.

    • @contomo5710
      @contomo5710 Год назад

      how did you adjust the timers for the adc? on the F401 i cant find an ADC clock

  • @kokoianer
    @kokoianer 3 года назад +28

    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)

    • @gabrielfienco2531
      @gabrielfienco2531 3 года назад +5

      Thank you man!!! almost 1 day debugging and trying to find out why!!!!.. your solution solve it in seconds hehe

    • @ThanwaSripramong
      @ThanwaSripramong 3 года назад +2

      Thank you so much, you saved my life on this...

    • @erichoward6766
      @erichoward6766 3 года назад +2

      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!

    • @dancruz21
      @dancruz21 3 года назад

      Thank you so much, this really saved me

    • @ycxv9661
      @ycxv9661 3 года назад +2

      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.

  • @briandecker4597
    @briandecker4597 8 месяцев назад

    Nice Video. Thanks for uploading

  • @KanagachidambaresanGR
    @KanagachidambaresanGR 2 года назад +2

    How many samples per second can be achieved???., Please let me know., i am working on Audio signal

  • @MaximeGiachetti
    @MaximeGiachetti 5 дней назад

    Thx for your help !

  • @GreenGuyDIY
    @GreenGuyDIY 9 месяцев назад

    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.

  • @RixtronixLAB
    @RixtronixLAB 2 года назад +1

    Nice info, thank you for sharing it :)

  • @dajianghe
    @dajianghe Год назад

    I got valid reading for only one channel; the other one is always 0. What could be the problem?

  • @eduardodelarosaferrer2205
    @eduardodelarosaferrer2205 3 года назад

    A flawless video

  • @robc3863
    @robc3863 2 года назад

    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?

  • @ubaidullah6261
    @ubaidullah6261 2 года назад +1

    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

    • @yogaline8218
      @yogaline8218 2 года назад

      I also would like to use ADC1 and ADC2 at the same time. Did you find any information how to do it? Thanks!

  • @MyMcMichael
    @MyMcMichael 2 года назад

    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?

    • @veikkoimmonen7300
      @veikkoimmonen7300 3 месяца назад

      You can set the conversion to run continuously in the background, so that you will only need to call start once. The interrupt will fire once every time the buffer is filled. You can even set it up to fire separate interrupts for "buffer half full" and "buffer full", which allows you to do double buffering (useful if you need to do heavy processing on the samples while new ones are being captured).

  • @mikeschem6441
    @mikeschem6441 2 года назад

    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?

    • @yogaline8218
      @yogaline8218 2 года назад

      I also would like to use ADC1 and ADC2 at the same time. Did you find any information how to do it? Thanks!

    • @robertsutherland3303
      @robertsutherland3303 Год назад

      @@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)

    • @veikkoimmonen7300
      @veikkoimmonen7300 3 месяца назад

      Set up for continuous conversions and use a bigger buffer. Then for the DMA start function, tell the size of the buffer - you will get an interrupt once the buffer is filled.

  • @williamrose3191
    @williamrose3191 Год назад

    awesome video. How can i do this with a timer?

    • @randomrickUK
      @randomrickUK  Год назад

      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

  • @zeeshantahir185
    @zeeshantahir185 11 месяцев назад

    You didn't setup multiple ADCs via DMA, rather multiple channels on single ADC. Caption is bit confusing

  • @luisnunes24
    @luisnunes24 3 года назад

    Awesome Video!!
    Could you post the code in the description?

  • @lordozi3113
    @lordozi3113 2 года назад

    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

    • @ntal5859
      @ntal5859 2 года назад

      You probably got the RANK out of order then...

  • @antoniocarbajal8009
    @antoniocarbajal8009 2 года назад

    Thank for you jobm it was good

  • @patrickschwarzenecker670
    @patrickschwarzenecker670 2 года назад

    thx

  • @contomo5710
    @contomo5710 Год назад

    the ending gave me schizophrenia