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.

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

  • @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.

  • @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 2 года назад +2

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

    • @erichoward6766
      @erichoward6766 2 года назад +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 2 года назад

      Thank you so much, this really saved me

    • @ycxv9661
      @ycxv9661 2 года назад +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.

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

    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 11 месяцев назад

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

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

    Nice Video. Thanks for uploading

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

    Nice info, thank you for sharing it :)

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

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

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

    A flawless video

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

    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.

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

    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?

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

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

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

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

  • @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 Год назад

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

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

    Thank for you jobm it was good

  • @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?

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

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

  • @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 Год назад

      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)

  • @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 Год назад

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

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

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

    thx

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

    the ending gave me schizophrenia