STM32H7 ADC + DMA + Timer Firmware Tutorial - Phil's Lab

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

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

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

    Thank you so much. I was struggling to get the DMA to work with the ADC on an H7, and this was incredibly helpful to find a solution.

  • @derivativ3
    @derivativ3 6 месяцев назад +26

    I've been looking for a tutorial on H7 ADCs for a while now, perfect timing with a new project!!
    your content is a literal goldmine and is getting so many of my friends into the embedded world

    • @PhilsLab
      @PhilsLab  6 месяцев назад +4

      Thank you so much, I'm very glad to hear that!

  • @nicktyler1836
    @nicktyler1836 23 дня назад

    The section about H7 caches, MPU, and linker scripts helped me overcome a horrible DMA bug at work today - thank you for the excellent worked example Phil. Super helpful.

  • @ericmin832
    @ericmin832 6 месяцев назад +18

    Funny, I was ripping my hair apart the past week trying to figure this out for a school project. Just when I thought all hope was lost, our lord and savior Phil descends from the heavens.
    I truly can't thank you enough Phil, your videos make my life so much easier!!!

    • @PhilsLab
      @PhilsLab  6 месяцев назад +4

      Haha thank you, Eric - glad the videos have been helpful!

    • @ericmin832
      @ericmin832 6 месяцев назад +2

      @@PhilsLab I just got ADC+DMA working with my STM32H750 board. Your video helped me get it up and running in just an hour when all other online guides didn't seem to work. Thank you!

  • @duke_of_oz
    @duke_of_oz 4 месяца назад +1

    As is often the case with stm32 materials, one must read hundreds of pages of datasheets and application notes to understand what yo have covered in 14:21 mins. Brilliant tutorial, thank you!

  • @pantelisEVs
    @pantelisEVs 6 месяцев назад +7

    Loved the MPU wenthrough. Really nice and clear explanation. Tweaks in mpu really handy when you play around with dma and peripherals!
    Thanks!

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

      Thanks a lot!

  • @samanmoghanloo7419
    @samanmoghanloo7419 6 месяцев назад +1

    This video was the best stm32 tutorial for a stm32 beginner like me. I followed your instruction with my stm32f103 and it worked like a charm and for the first time with stm32, I didn't face any issues while programming. huge thanks for making such a content.

  • @gosdeCarrer
    @gosdeCarrer 6 месяцев назад +5

    I have just done the same things but a with an STM32F4; ADC + timer + DMA to sample ultrasonic sounds from bats, up to 115Khz, so a sample rate of about 240KHz. Then in real time do the FFT to identify the peak frequencies, draw an spectrogram, etc. I was just fighting with each and every of those settings in the cubeide 🙂, but it works very well.

  • @DrTimmay
    @DrTimmay 6 месяцев назад +14

    Good stuff! The H7x5/H7x3 series of this chip is a monster at 520MHz (550Mhz if you're willing to disable ECC). Though with that comes some nutty power domain complexity... Much more involved than the G4 series.

    • @PhilsLab
      @PhilsLab  6 месяцев назад +3

      Thanks! Definitely, I use the H7 in quite a number of projects and it's possibly my favourite MCU.

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

      Do you happen to have an app note and page number where they explain that you need to disable EEC when running in boost mode at 550MHz? I have some programs running with EEC enabled on AXI SRAM at 550MHz on an H723, and I never receive any warnings from STM32Cube IDE like you normally would when peripherals are clocked too high, but that could be a bug, of course. The MCU runs just fine without problems. 🤔

    • @ChiefBridgeFuser
      @ChiefBridgeFuser 6 месяцев назад +1

      Still a monster at the 280ish MHz flavors too. We have been bitten by the cache in an H7B0... If we'd read more of the datasheet & ref manual we'd have been less dumb in porting some of out old code over.😮

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

      @@PeetHobby From the reference manual about the `CPU_FREQ_BOOST` bit in `SYSCFG` (section 12.4.26, at least in my revision): `When this bit is set, the CPU maximum frequency is boosted and the ECC on ITCMRAM and DTCM-RAM are no more used.` Without `CPU_FREQ_BOOST` you're only able to use `VOS0`, which according to the datasheet is limited to 520MHz (DS table 13: General Operating Conditions)

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

      @@PeetHobby Rereading your comment again, sounds like you're in the clear: since you're using AXI SRAM the ITCM RAM is disabled, and at least from what I can tell from the reference manual you should be good to go since it only affects the ECC on ITCM and DTCM.

  • @bubbasplants189
    @bubbasplants189 5 месяцев назад

    Great example, I've been following your videos for some time. So far I've been able to set up and program my custom board to interact with an I2C sensor and send data through USB com port!

  • @EmbeddedEnigma
    @EmbeddedEnigma 5 месяцев назад

    Amazing video as usual, also looked at your previous DSP videos to learn more about dsp algos and DMA, as I recently got an project related to DSP so started to get more involved into it. Keep uploading videos like these really help full.

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

    24:00 I always like to reinforce the idea of using the slope intercept formula to convert the ADC to pretty much any value you need. I haven't done any graphing whether the output is exactly linear, but I feel it is a good approximation. Your explanation is perfect and thoroughly enjoyed the video.

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

      Thanks! Yep, if there is an offset that's the way to go! Usually the calibration is enough to remove the offset and then I just use the slope, as shown in the video.

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

      Sometimes a linear cal is needed to compensate for offset and gain errors in signal conditioning and sensing circuitry.

  • @madrigo
    @madrigo 6 месяцев назад +1

    Can't thank you enough for your content Phil! With your series of videos, one like myself can work on a complete DSP design based on a H7 core. Appreciate your work mate!!

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

      Thank you, I'm glad to hear that this helps with your DSP design!

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

    Thank you for the content. Please never stop doing videos!

  • @andy-bandy
    @andy-bandy 6 месяцев назад +2

    Hahah I was already trying to design a stm32h7 board, and you upload this, perfect timing

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

    Man, I reallt could've used this in some previous projects. Thanks a million as always.

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

    Thx for another great video. I am working with AVR stuff(SAM) but i want to use DMA in the future. This gave me a better understanding on how the concept of DMA basically works. Have a nice weekend!

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

      Glad to hear that, thanks!

  • @wisamal-hitari1734
    @wisamal-hitari1734 2 месяца назад

    thank you so much. That really helped me a lot in my project

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

    Great explanation of a very interesting topic.

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

      Thanks, Isaac!

  • @peterwang7608
    @peterwang7608 26 дней назад +1

    Can the input signals on their selected channels of all SAR ADC0, ADC1, ADC2 in STM32H753 be sampled synchronously under the same sampling rate? (For an example, triggered by the same timer?)

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

    I have been working on the ADC of the F7 F4 and L4 series, the performance of these things are absolutely beasts. Sometimes I just keep several necleo boards around and use them as daq.🤣

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

    THANKS Philip you're the best !
    look for more creative projects

  • @plemli
    @plemli 6 месяцев назад +1

    Well explained. It'll surely save a lot of time for newcomers to the H7.

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

      Many thanks!

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

    Hi Phil, great video, thanks for it! I think that maybe the generated code for STM32U5 already calls those power enable functions when you use the respective peripherals. At least in a project I have here, I use the ADC and HAL_PWREx_EnableVddA() is called inside HAL_MspInit(). I did not test for USB and PG IO's.

  • @fedimakni1200
    @fedimakni1200 6 месяцев назад +1

    For power filtering, i always see people (such as altium academy and other) always mention to not use ferrite beads and other options are better. Do you support the same position or you think it's ok to use them? are there other ways to filter the 3.3V power line you showed in the video? thanks
    Their claim is that ferrite can cause unforeseen problems as it can resonate and cause problems when high switching element such as ICs and uC are connected to, and the only OK way to use it is with DC loads.

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

      It’s a valid concern. Ferrite beads form a resonant tank circuit, so the pulse of current an ADC creates during the sample and hold capacitor charging can set it ringing. If you’re sampling near the resonant frequency, you’ll get a buildup of this oscillation and your sampled values will be all over the place. A simple RC filter which you can design to be below your sampling frequency is much more forgiving and predictable.

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

      In the prototyping stage, I like to add in series elements (beads/0R resistors) to be able to change them out/create/adjust filters if needed (rather than not have that option at all to begin with). Then, working towards the final product, if needed, they can be omitted or different values can be chosen.

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

    Thank you! Waiting for mentioned future video. Im working with H7 for some time and caching in topic Id like to introduce in HMI project

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

    That cap in the potentiometer circuit is more than just a low pass filter. These converters are capacitive ladder and draw a spike of current / charge when they sample. The cap is a cheap easy way to provide this charge and eliminate a strange error you will see otherwise, as long as you can live with your chosen cutoff frequency.

  • @PeetHobby
    @PeetHobby 6 месяцев назад +1

    Great video again, just up my alley. 😁
    What is not 100% clear to me after some testing with the H723 and H750 is whether it's best to use SRAM that is in the domain of the DMA controller that is being used. From what I understand, if you use an SRAM block in a different domain than the DMA controller, the data needs to be passed through a 32-bit AHB bus to the other domain. For example, if you use AXI SRAM in domain 1 for the DMA buffer and the DMA1 controller located in domain 2, the data will pass via the 32-bit D1-to-D2 AHB bus that connects domain 1 and domain 2. This will take extra cycles or not?
    Additionally, I found that, for example, the BDMA controller can only access SRAM4 in domain 3, and DMA1 and DMA2 don't have access to SRAM4 in domain 3, and vice versa. So, I made sections for the different SRAMs in the linker file and used the compiler command to store the buffer in that section with attribute((section("blablabla"))). Not fully sure if this is the way to go, but at least I can use all the sram that is across the domeins.
    The so-called master DMA, MDMA, is a very useful peripheral. Last week I've tested its link capabilities, which can be triggered by other DMAs and can set/clear flags and such. Made code that when I start DMA2D transfer(normal hal function), it's triggers MDMA when complete, and MDMA copies data from DMA2D buffer into SPI buffer that is refreshing the screen. It's a very simple linked list but it's done without any CPU intervention.

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

      Thank you! Those are great points - yes, I believe it's important to watch out that ideally the DMA controllers have 'direct access' to the memory regions, if performance is critical (e.g. in real-time DSP systems).
      For something like the pot sampling in this video I'm usually not too worried.

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

    I love the stream of consciousness here. It all makes a lot of sense, I'm just lacking the context of what this is all aiming to do! Maybe there's a video that I missed.

  • @erik3208
    @erik3208 6 месяцев назад +1

    What is your take on ferrite beads? Many reputable people tells you to avoid them, usually.

    • @simontillson482
      @simontillson482 6 месяцев назад +1

      They’re useful for reducing EMI to get through testing, on power lines which might otherwise feed back high frequencies or sharp edges onto supply lines, but should be avoided in analog filtering due to their resonant properties. As with most components, there are places they are useful, and places where they are a disaster.

    • @PhilsLab
      @PhilsLab  6 месяцев назад +1

      In the prototyping stage, I like to add in series elements (beads/0R resistors) to be able to change them out/create/adjust filters if needed (rather than not have that option at all to begin with). Then, working towards the final product, if needed, they can be omitted or different values can be chosen.

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

    Another great, and timley video again as I'm wrestling with the ADCs on a Nuceleo-H743ZI2!
    I've followed everything, but I still get zeros in the live expressions when debugging and I'm not sure where I'm going wrong with this :(
    In the demo section where you have working values in the live expressions have you already done the cache control changes? I've tried the changes outlined but no avail. The nucelo I'm using has different memory regions to the H7 used in your demo. I have:
    FLASH, DTCMRAM, RAM_D1, RAM_D2, RAM_D3, ITCMRAM.
    Does it matter which I choose? I arbitrarily tried RAM_D3.
    Finally, you say this reduces the speed - I'm shooting for around 2 Msamples/s for my final goal. Will I run into problems with the cache here?
    Thanks again for the great video!

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

      So I have no idea what I did, but I got it working. I think it may have been that the clock speeds were too high?

  • @rongwang1296
    @rongwang1296 25 дней назад

    Can all selected channels of each SAR ADC(0, 1,2) be trigged by the same timer event settings so that they can be sampled simultaneously?

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

    You know I've been bashing my head against this on a h7 for the last 3 days, i just get it all working at 2AM and *now* you post this video?
    Jerk 😂

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

      Haha sorry :D

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

    nice video phil... thanks for sharing...

    • @PhilsLab
      @PhilsLab  6 месяцев назад +1

      Thanks for watching, Gabriel!

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

    My brain now hurts. Thank you.

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

    Phill you gonna make more online courses with STM32? Wold be nice about programing STM32. I liked a lot the cource hardware desing with kicad.

  • @Danny-g9f
    @Danny-g9f 3 месяца назад

    is there a way to prevent the cubemx tool from overwriting your changes in the linker file to add your own attribute section (there are no user code sections in the linker file)?

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

    Hello Phil's Lab, could you recommend me a microcontroller that I could use to control the gates of the two keying bridges. It is important that it generates PWM signals with a sine structure. Moreover, the two sine functions created in this way must be mutually shifted by an angle of 90 degrees regardless of the frequency within 0 - 500 Hz. PWM carrier frequency not less than 15 kHz.
    Ultimately, the system is to power the gates of 8 IGBT switching transistors of my 6 kW new generation Brushless Hybrid Fast - Rotation Motor.
    Thank you in advance and best regards 👋😀💖.

  • @adriftfoolish1
    @adriftfoolish1 5 месяцев назад

    Pawtem-chomiter ❤

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

    great video !!!! love it!

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

      Thank you!

  • @encoderencoder1031
    @encoderencoder1031 5 месяцев назад

    Does the live expression available on stm32g0 series?

  • @darioljubas3085
    @darioljubas3085 5 месяцев назад

    I am working on a similar project, and I'm stuck when i need to send data via uart back to pc? Any ideas how to fix that?

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

    please make a video about EatherCAT ET1100 ASIC pcb desing

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

    Nice video!

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

      Thanks, Tony!

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

    Need lesson about i2s on stm32h7! I have f303 and no problems on it, but on h750 a have an underrun error

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

      That's definitely a video to come in the near future :)

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

      @@PhilsLab Excellent!! I have been hoping to see that set up. It's been a while since I looked, but the details for setting up DMA with i2s on H7 are hard to find online.

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

    phil pleas next video on STM32 Digital PFC boost converter .

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

    Hey Phil. Do you always use HAL? I personally never use HAL, everything will be coded on register level.

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

      Yep! Personally, it just allows me to get to the core of the actual project much quicker.

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

      hey, quick question. why not use HAL? is it because the abstraction layer abstracts so much that it takes away the control you have over the MPU or are you just used to doing it without any abstraction layers? thank you for your reply in advance.

  • @Εὐκλείδης300
    @Εὐκλείδης300 6 месяцев назад

    BEST!!!😀

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

      Thank you!

  • @tamaseduard5145
    @tamaseduard5145 6 месяцев назад +1

    👍🙏❤️

  • @jatigre1
    @jatigre1 5 месяцев назад

    Wow, someone turned the difficulty dial to 11.