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.
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 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!
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
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.
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!
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.
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.
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. 🤔
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.😮
@@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)
@@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.
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!!
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!
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.
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.
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.
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.🤣
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.
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!
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?)
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.
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.
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.
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.
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.
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.
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.
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.
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.
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)?
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 👋😀💖.
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!
@@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.
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.
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.
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!!!
Haha thank you, Eric - glad the videos have been helpful!
@@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!
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
Thank you so much, I'm very glad to hear that!
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.
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!
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.
Loved the MPU wenthrough. Really nice and clear explanation. Tweaks in mpu really handy when you play around with dma and peripherals!
Thanks!
Thanks a lot!
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.
Thanks! Definitely, I use the H7 in quite a number of projects and it's possibly my favourite MCU.
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. 🤔
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.😮
@@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)
@@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.
Thank you for the content. Please never stop doing videos!
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!!
Thank you, I'm glad to hear that this helps with your DSP design!
Hahah I was already trying to design a stm32h7 board, and you upload this, perfect timing
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!
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.
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.
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.
Sometimes a linear cal is needed to compensate for offset and gain errors in signal conditioning and sensing circuitry.
Man, I reallt could've used this in some previous projects. Thanks a million as always.
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.🤣
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.
thank you so much. That really helped me a lot in my project
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!
Glad to hear that, thanks!
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?)
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.
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.
THANKS Philip you're the best !
look for more creative projects
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
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.
Great explanation of a very interesting topic.
Thanks, Isaac!
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.
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?
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.
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.
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.
Well explained. It'll surely save a lot of time for newcomers to the H7.
Many thanks!
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.
What is your take on ferrite beads? Many reputable people tells you to avoid them, usually.
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.
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.
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)?
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 😂
Haha sorry :D
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 👋😀💖.
Does the live expression available on stm32g0 series?
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?
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!
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?
nice video phil... thanks for sharing...
Thanks for watching, Gabriel!
please make a video about EatherCAT ET1100 ASIC pcb desing
phil pleas next video on STM32 Digital PFC boost converter .
My brain now hurts. Thank you.
Need lesson about i2s on stm32h7! I have f303 and no problems on it, but on h750 a have an underrun error
That's definitely a video to come in the near future :)
@@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.
great video !!!! love it!
Thank you!
Pawtem-chomiter ❤
Nice video!
Thanks, Tony!
Hey Phil. Do you always use HAL? I personally never use HAL, everything will be coded on register level.
Yep! Personally, it just allows me to get to the core of the actual project much quicker.
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.
BEST!!!😀
Thank you!
👍🙏❤️
Wow, someone turned the difficulty dial to 11.