Тёмный

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

Phil’s Lab
Подписаться 154 тыс.
Просмотров 15 тыс.
50% 1

ADC set-up with DMA streams and sampling timer for STM32 microcontrollers. Tips on working with H7's D-cache and memory protection unit (MPU). PCBs by PCBWay www.pcbway.com
[SUPPORT]
Hardware design courses: phils-lab-shop.fedevel.education
Course content: www.phils-lab.net/courses
Patreon: / phils94
Free trial of Altium Designer: www.altium.com/yt/philslab
Altium 365: www.altium.com/altium-365
[GIT]
www.github.com/pms67
[SOCIAL]
/ philslabyt
[LINKS]
AN2834: www.st.com/resource/en/applic...
Getting Started with ADCs: wiki.stmicroelectronics.cn/st...
STM32CubeIDE: www.st.com/en/development-too...
DSP Overdrive Algorithm: • DSP Overdrive Algorith...
[TIMESTAMPS]
00:00 Introduction
02:34 PCBWay
03:05 Hardware Overview
05:36 ADC Considerations
07:54 ADC Config
14:06 DMA Config
15:28 Timer & Clock Config
19:35 Firmware Implementation
22:41 ADC Callback
25:19 Demo
27:07 H7 Caches, MPU, Linker Script
32:34 U5 DMA, Power Domains
34:53 Outro

Наука

Опубликовано:

 

17 июн 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 67   
@derivativ3
@derivativ3 17 дней назад
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 17 дней назад
Thank you so much, I'm very glad to hear that!
@samanmoghanloo7419
@samanmoghanloo7419 3 дня назад
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.
@ericmin832
@ericmin832 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 17 дней назад
Haha thank you, Eric - glad the videos have been helpful!
@ericmin832
@ericmin832 17 дней назад
@@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!
@gosdeCarrer
@gosdeCarrer 17 дней назад
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.
@severingetzner8211
@severingetzner8211 4 дня назад
Thank you for the content. Please never stop doing videos!
@pantelisEVs
@pantelisEVs 17 дней назад
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 17 дней назад
Thanks a lot!
@andy-bandy
@andy-bandy 17 дней назад
Hahah I was already trying to design a stm32h7 board, and you upload this, perfect timing
@markhofmeister702
@markhofmeister702 17 дней назад
Man, I reallt could've used this in some previous projects. Thanks a million as always.
@DrTimmay
@DrTimmay 17 дней назад
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 17 дней назад
Thanks! Definitely, I use the H7 in quite a number of projects and it's possibly my favourite MCU.
@PeetHobby
@PeetHobby 17 дней назад
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 17 дней назад
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 17 дней назад
@@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 17 дней назад
@@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.
@madrigo
@madrigo 17 дней назад
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 17 дней назад
Thank you, I'm glad to hear that this helps with your DSP design!
@blackxiivexil8255
@blackxiivexil8255 17 дней назад
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 17 дней назад
Glad to hear that, thanks!
@user-lk5jq2qb6j
@user-lk5jq2qb6j 16 дней назад
THANKS Philip you're the best ! look for more creative projects
@isaacclark9825
@isaacclark9825 17 дней назад
Great explanation of a very interesting topic.
@PhilsLab
@PhilsLab 17 дней назад
Thanks, Isaac!
@gabrielvigiano
@gabrielvigiano 17 дней назад
nice video phil... thanks for sharing...
@PhilsLab
@PhilsLab 17 дней назад
Thanks for watching, Gabriel!
@wodddj
@wodddj 13 дней назад
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.🤣
@Pyrografpl
@Pyrografpl 15 дней назад
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
@PatrickHoodDaniel
@PatrickHoodDaniel 17 дней назад
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 17 дней назад
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 17 дней назад
Sometimes a linear cal is needed to compensate for offset and gain errors in signal conditioning and sensing circuitry.
@adjbutler
@adjbutler 17 дней назад
great video !!!! love it!
@PhilsLab
@PhilsLab 17 дней назад
Thank you!
@MarceloRobertoJimenez
@MarceloRobertoJimenez 15 дней назад
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.
@tonygiguere2495
@tonygiguere2495 17 дней назад
Nice video!
@PhilsLab
@PhilsLab 17 дней назад
Thanks, Tony!
@plemli
@plemli 17 дней назад
Well explained. It'll surely save a lot of time for newcomers to the H7.
@PhilsLab
@PhilsLab 17 дней назад
Many thanks!
@r7boatguy
@r7boatguy 17 дней назад
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.
@oididdidi
@oididdidi 17 дней назад
My brain now hurts. Thank you.
@ChiefBridgeFuser
@ChiefBridgeFuser 17 дней назад
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.
@user-om7os8gj8x
@user-om7os8gj8x 17 дней назад
BEST!!!😀
@PhilsLab
@PhilsLab 17 дней назад
Thank you!
@zyeborm
@zyeborm 17 дней назад
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 17 дней назад
Haha sorry :D
@rodrigobrasilia7506
@rodrigobrasilia7506 15 дней назад
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.
@PeetHobby
@PeetHobby 17 дней назад
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 17 дней назад
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.
@smartups1
@smartups1 16 дней назад
phil pleas next video on STM32 Digital PFC boost converter .
@tamaseduard5145
@tamaseduard5145 17 дней назад
👍🙏❤️
@fedimakni1200
@fedimakni1200 17 дней назад
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 17 дней назад
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 17 дней назад
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.
@erik3208
@erik3208 17 дней назад
What is your take on ferrite beads? Many reputable people tells you to avoid them, usually.
@simontillson482
@simontillson482 17 дней назад
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 17 дней назад
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 День назад
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 13 часов назад
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?
@9782ravi
@9782ravi 7 дней назад
please make a video about EatherCAT ET1100 ASIC pcb desing
@olivie1995
@olivie1995 17 дней назад
Need lesson about i2s on stm32h7! I have f303 and no problems on it, but on h750 a have an underrun error
@PhilsLab
@PhilsLab 17 дней назад
That's definitely a video to come in the near future :)
@isaacclark9825
@isaacclark9825 17 дней назад
@@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.
@TriodeTetrode
@TriodeTetrode 17 дней назад
Hey Phil. Do you always use HAL? I personally never use HAL, everything will be coded on register level.
@PhilsLab
@PhilsLab 17 дней назад
Yep! Personally, it just allows me to get to the core of the actual project much quicker.
@hachikiina
@hachikiina 17 дней назад
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.
Далее
SPI Hardware & PCB Design - Phil's Lab #134
33:22
Просмотров 23 тыс.
Every Home needs this Upgrade! (Control EVERYTHING)
11:14
Stupid Barry Searches Prisoners Feat. Mellstroy
00:25
Просмотров 911 тыс.
World’s Deadliest Obstacle Course!
28:25
Просмотров 73 млн
I Built a SECRET Tree House in My Backyard!
26:09
Просмотров 3,5 млн
Understanding SPI
11:50
Просмотров 66 тыс.
Open Source Analog ASIC design: Entire Process
40:11
Просмотров 19 тыс.
6 Horribly Common PCB Design Mistakes
10:40
Просмотров 171 тыс.
PCB Chip Antenna Hardware Design - Phil's Lab #139
32:34
The Magic of RISC-V Vector Processing
16:56
Просмотров 191 тыс.
2-Layer PCB Design Tips - Phil's Lab #137
32:27
Просмотров 33 тыс.
Калькулятор в iPadOS 18 ➕
0:38
Просмотров 149 тыс.
Face ID iPhone 14 Pro
0:59
Просмотров 18 тыс.