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

Поділитися
Вставка
  • Опубліковано 26 лис 2024

КОМЕНТАРІ • 81

  • @nicktyler1836
    @nicktyler1836 День тому

    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 5 місяців тому +17

    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  5 місяців тому +4

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

    • @ericmin832
      @ericmin832 5 місяців тому +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!

  • @derivativ3
    @derivativ3 5 місяців тому +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  5 місяців тому +4

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

  • @gosdeCarrer
    @gosdeCarrer 5 місяців тому +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.

  • @duke_of_oz
    @duke_of_oz 3 місяці тому

    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!

  • @samanmoghanloo7419
    @samanmoghanloo7419 5 місяців тому +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.

  • @pantelisEVs
    @pantelisEVs 5 місяців тому +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  5 місяців тому

      Thanks a lot!

  • @DrTimmay
    @DrTimmay 5 місяців тому +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  5 місяців тому +3

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

    • @PeetHobby
      @PeetHobby 5 місяців тому

      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 5 місяців тому +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 5 місяців тому

      @@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 5 місяців тому

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

  • @severingetzner8211
    @severingetzner8211 5 місяців тому

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

  • @madrigo
    @madrigo 5 місяців тому +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  5 місяців тому

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

  • @andy-bandy
    @andy-bandy 5 місяців тому +2

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

  • @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 5 місяців тому

    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  5 місяців тому

      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 5 місяців тому

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

  • @markhofmeister702
    @markhofmeister702 5 місяців тому

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

  • @wodddj
    @wodddj 5 місяців тому

    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.🤣

  • @ChiefBridgeFuser
    @ChiefBridgeFuser 5 місяців тому

    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.

  • @wisamal-hitari1734
    @wisamal-hitari1734 Місяць тому

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

  • @blackxiivexil8255
    @blackxiivexil8255 5 місяців тому

    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  5 місяців тому

      Glad to hear that, thanks!

  • @peterwang7608
    @peterwang7608 4 дні тому +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?)

  • @PeetHobby
    @PeetHobby 5 місяців тому +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  5 місяців тому

      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.

  • @MaiKhurais
    @MaiKhurais 5 місяців тому

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

  • @Pyrografpl
    @Pyrografpl 5 місяців тому

    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

  • @MarceloRobertoJimenez
    @MarceloRobertoJimenez 5 місяців тому

    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.

  • @isaacclark9825
    @isaacclark9825 5 місяців тому

    Great explanation of a very interesting topic.

    • @PhilsLab
      @PhilsLab  5 місяців тому

      Thanks, Isaac!

  • @r7boatguy
    @r7boatguy 5 місяців тому

    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.

  • @rongwang1296
    @rongwang1296 3 дні тому

    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?

  • @fedimakni1200
    @fedimakni1200 5 місяців тому +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 5 місяців тому

      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  5 місяців тому

      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.

  • @plemli
    @plemli 5 місяців тому +1

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

    • @PhilsLab
      @PhilsLab  5 місяців тому

      Many thanks!

  • @rodrigobrasilia7506
    @rodrigobrasilia7506 5 місяців тому

    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.

  • @erik3208
    @erik3208 5 місяців тому +1

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

    • @simontillson482
      @simontillson482 5 місяців тому +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  5 місяців тому +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.

  • @Danny-g9f
    @Danny-g9f 2 місяці тому

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

  • @zyeborm
    @zyeborm 5 місяців тому

    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  5 місяців тому

      Haha sorry :D

  • @ZygmuntKiliszewski
    @ZygmuntKiliszewski 5 місяців тому

    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 👋😀💖.

  • @encoderencoder1031
    @encoderencoder1031 4 місяці тому

    Does the live expression available on stm32g0 series?

  • @darioljubas3085
    @darioljubas3085 4 місяці тому

    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?

  • @ZozobraDoom
    @ZozobraDoom 5 місяців тому

    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 5 місяців тому

      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?

  • @gabrielvigiano
    @gabrielvigiano 5 місяців тому

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

    • @PhilsLab
      @PhilsLab  5 місяців тому +1

      Thanks for watching, Gabriel!

  • @9782ravi
    @9782ravi 5 місяців тому

    please make a video about EatherCAT ET1100 ASIC pcb desing

  • @smartups1
    @smartups1 5 місяців тому

    phil pleas next video on STM32 Digital PFC boost converter .

  • @oididdidi
    @oididdidi 5 місяців тому

    My brain now hurts. Thank you.

  • @olivie1995
    @olivie1995 5 місяців тому

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

    • @PhilsLab
      @PhilsLab  5 місяців тому

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

    • @isaacclark9825
      @isaacclark9825 5 місяців тому

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

  • @adjbutler
    @adjbutler 5 місяців тому

    great video !!!! love it!

  • @adriftfoolish1
    @adriftfoolish1 4 місяці тому

    Pawtem-chomiter ❤

  • @tonygiguere2495
    @tonygiguere2495 5 місяців тому

    Nice video!

    • @PhilsLab
      @PhilsLab  5 місяців тому

      Thanks, Tony!

  • @TriodeTetrode
    @TriodeTetrode 5 місяців тому

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

    • @PhilsLab
      @PhilsLab  5 місяців тому

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

    • @hachikiina
      @hachikiina 5 місяців тому

      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 5 місяців тому

    BEST!!!😀

  • @tamaseduard5145
    @tamaseduard5145 5 місяців тому +1

    👍🙏❤️

  • @jatigre1
    @jatigre1 5 місяців тому

    Wow, someone turned the difficulty dial to 11.