Great video. You are a pioneer in STM and ARM developer resources. Really glad to see your initiative to help the next generation move to the more advanced STM32 from Arduino.
Thank you very much! I tried around with HAL, which makes clock configuration very easy, but I found out that it is so much slower than writing directly to registers for GPIO ports (factor 10 perhaps). So I decided not to use HAL for my project, but I was stuck a whole day with the clock configuration. I think the most part of it was fine, but the mistake was not to wait for the clocks to be ready like in your video. That helped and now it works! I will watch your other videos to avoid problems when moving on with the project!
Awesome video. Thanks, it helps take the scary part of bare metal coding away. I will be looking forward to the rest of the videos in this series. I presume that code written like this takes much less memory so those of us using the free version of Keil can do more within its code size limitations. Thanks again.
You are certainly the best when it comes to putting together videos on STM ARM. Please consider publishing a book or putting a course up on one of the MOOC providers.
That's how I first learned to program stm32 . The manual explains in terms of the registers so it's the obvious way to get started. The HAL Low Level drivers are perfect for register programming because the way the functions are written self documents your code. After a while though you'll want to use HAL drivers as they offer a good high level way to get things done.
Thanks for the great videos! One request, please find a way to keep the ads on your website from covering the tutorial information. Also, If I resize the browser, so I can fit both my IDE and the browser side-by-side, all of the ads cover up the information as well.
The HAL in stm series is only meant for those who are already good in register level programming, learners can never learn register level programming by that,... this is the video i can easily understand what the hell is happening ,thanks a lot sir
HAL is easier compared to registers. I don't think you need to know registers to program in HAL. Obviously registers gives you more control over your MCU.
I appreciate the detail, including referencing CubeMX and the programming manual. The background music was a bit distracting. As a matter of coding style, when you have a while loop that has no body (where you are waiting for the HSE and PLL to become ready), I think it helps to use curly braces, or put the semicolon on the next line (ideally with a comment like "do nothing" or "wait until ready". A semicolon at the end of the line with the "while" keyword is easy to overlook, or looks like a function call.
Brillant tutorial absolutly love it. You did enable external oscillator which exactly doesn't exist as we can see on the board. I think you should choose Bypass clock source. What exactly running now this ARM - Bypass clock source or internal oscillator?
Thank you for the video. I have doubt, that the Nucleo board used in this video no external oscillator is connected, but we have programmed the controller as an external oscillator. Please tell us how.
I like your approach to non-HAL coding for setup and configuration of the MCU system and peripheral blocks. I do however miss the easy access to useful Arduino functions e.g. map(), now I know this could be hand coded but would it be possible to add an Arduino header file that contains these functions. For example I noticed in VSC-PlatformIO that when developing an ESP32 project, and probably other MCUs, an #include is automatically added, which does enable Map(), and presumably the rest of the Arduino functions, to be used; I would really like to see a video on this subject.
You can create one header file yourself consisting of all those functions.. I don't think it's necessary to make a video on that. Just google the source code of those functions and collect them at one place
Very good, I really learned a lot ... I just need a clarification on Clock Configuration in Cube MX: I am using a STM32F401RE Nucleo board and I intend to use the 8Mhz ST-Link Oscillator on the board, is this still to be configure as crystal/ceramic Resonator or as Bypass clock source ... Thank you
Thanks for this video. However in configure target options the xtal frequency is greyed out and I cannot change. Could you suggest How can I change the frequency. I am using STM32F401CCU6 microcontroller and I need to give 84 Mhz.
@@sushivamsingh8069 As you can see in the video it properly worked without using "volatile". However we followed the steps of the video and done exactly the same thing. So what is the difference, why we need "volatile"?? We need it because our compilers differ. Let's look at the functions body: while(time--); If it is true time is decremented. The function returns nothing, and after execution the value of time is lost. In our case the compiler just thought: "Hey here is a function that gets a parameter, but wait!! any modification we make on that will be lost and we don't even use it in any proper conditions. Then why should I contain this parameter in that function? Let's just skip it to optimize runtime and memory." In the video the other compiler thought it might be important so compiled it. If we make a variable "volatile", we tell the compiler that don't make any excuses and skip, just compile it as it is. Most of the time when you interact with hardware it is out of the compiler's scope, for example it can't see if a variable is modified by hardware, in these cases the code will only work if you use volatile variables.
Hi, I have STM32F4 Discovery but I have difficulties setting up the clock. I checked the reference manuals for register differences, I checked the syntax but I didn’t find any problems. When I download the code to the Discovery Board regardless of the delay function my LEDs just lights up dim and doesn’t blink or do anything really. I had check delay but it's not work. Can you help with this ?
Great video. But how could i know the steps? Every moment i have more questions… How would i know to config the voltage regulator after enable APB? I can i develop that mind set to figure this kind of things be myself? I want to realy learn and not to be a copycat. Where it is written in the data sheet or manual reference? Please tell me the secret
Thank you for this tutorial! But how can we see our actual speed to check our code right or wrong? Because I finished this tutorial and now studying your tutorial about TIMER and USART, but my clock seems to run slower as expected. Therefore, 1 second (on TIMER tutorial) on my board is relatively slower than reality, and the Hercules software can't recognize the letter 'G' from the beginning.
In step 2, after I set the POWER ENABLE CLOCK in RCC_APB1ENR, how can I set the VOLTAGE REGULATOR because I'm using STM32F103C8 which doesn't have VOS in bit [15:14] like F446 does? And what is the purpose of this bit?
How do you know for sure that the HSE is operating at 8Mhz? Because I see in the file system_stm32f446xx.c is defining the HSE at 25Mhz #if !defined (HSE_VALUE) #define HSE_VALUE ((uint32_t)25000000) /*!< Default value of the External oscillator in Hz */ #endif /* HSE_VALUE */ #if !defined (HSI_VALUE) #define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/ #endif /* HSI_VALUE */ and I don't see you configuring the HSE's frequency back to 8Mhz.
"How do you know for sure that the HSE is operating at 8Mhz?" You can check the next video in the series, where the timer is being used to setup the exact delay using this configuration. "Because I see in the file system_stm32f446xx.c is defining the HSE at 25Mhz" That value will be used if you use the function SystemCoreClockUpdate(), which is also defined in the system file. If you enable the HSE crystal, it will simply run at it's clock, which is 8MHz in my case.
Well this one is not an ESP32 video. The ESP32 series doesn't have many videos yet, that's why they aren't arranged. So you just see what you are interested in.
Hi, I downloaded code and flash my Nucleo-F446RE board. The LED remains ON all the time, no blinking. Further, I also commented in the program:- Pin OUTPUT and while loop (shown below). still the LED is ON. I am surprised. What could be the reason, if any one have encountered this ? thank you // 2. Set the Pin as OUTPUT //GPIOA->MODER |= (1
Hello Sir , firstly thank u very much for such an awasome playlist . I want to ask a question that im struggling with over 3 days and couldnt solve the problem which is when i write above codes and watch the changes of PLLCFGR register , no bit changes . I try a lot of ways and i solved that by calling the function RCC_DeInit();. But why my codes cant work withour RCC_DeInit ? And how can i solve that problem ? Best Wishes.
@@ControllersTech stm32f407vet6 - discovery board - . Sir im still trying to find a solution but i cant solve even looked to over 30-40 projects on the internet . The main problem is : even if i assign any operation - such as RCC->PLLCFGR |= (1
The point with this series is not to involve cubemx... I only used it in this video for rcc setup. It's not involved in any other video in this series..
@@ControllersTechfirst thank you the quick response 👍👍👍👍👏👏👏. X1 can be used both for stlink and stm32f as HSE Is that correct, I had the doubt bcz X3 is empty in nucleo board..
8:09 Isn't it important what value is programmed first? Because when I write a value in the e.g. 4th bit of a register and then a value in the e.g. 6th bit then the first value will be overwritten or not?
@@ControllersTech Hmmm, then something must be wrong in some other code from me, there I must began from the MSB what I need to set. Otherwise the lower bits were overwritten. And I used OR and AND
@@ControllersTech I´ve played around a little bit with bitwise operations in C (not on a microcontroller) and when I do something like that: uint8_t test = 144; //(0b1001000) test &= (0
Hlo @ControllersTech, I am using STM32L476RGT6, I used the code as you have done in this video but I am not able to blink the led, can you please tell me what should I change to make it blink the led. Code: #include "stm32l476xx.h" void SysClockConfig(void); void GPIO_Config(void); void Delay(uint32_t delay); void SysClockConfig(void) { /* STEPS FOLLOWED 1. Enable HSE and wait for the HSE to become ready 2. Set the POWER ENABLE CLOCK and VOLTAGE REGULATOR 3. Configure the FLASH PREFETCH and the LATENCY related settings 4. Configure the PRESCALERS HCLK, PCLK1, PCLK2 5. Configure the MAIN PLL 6. Enable the PLL and wait for it to become ready 7. Select the Clock Source and wait for it to set */ #define PLL_M 4 #define PLL_N 80 #define PLL_P 0 // PLLP = 7 #define PLL_Q 0 // PLLQ = 2 #define PLL_R 0 // PLLR = 2 // Step 1 RCC->CR |= RCC_CR_HSEON; while(!(RCC->CR & RCC_CR_HSERDY)); // Step 2 RCC->APB1ENR1 |= RCC_APB1ENR1_PWREN; PWR->CR1 |= PWR_CR1_VOS; // Step 3 FLASH->ACR |= FLASH_ACR_ICEN | FLASH_ACR_DCEN | FLASH_ACR_LATENCY_4WS; // Step 4 RCC->CFGR |= RCC_CFGR_HPRE_DIV1; // AHB PRESCALER RCC->CFGR |= RCC_CFGR_PPRE1_DIV1; // APB1 PRESCALER RCC->CFGR |= RCC_CFGR_PPRE2_DIV1; // APB2 PRESCALER // Step 5 RCC->PLLCFGR |= (PLL_M
Its not written anywhere.. this something you learn by programming lower end mcus.. For some peripherals like uart, i2c you can see the reference manual.
Greetings, can someone explain to me why the author put 8 MHz instead of 25 MHz when configuring the timers in the CubeMX. And how it is reflected in the values that the author writes in the registers. Thanks in advance for your help.
We can't create the project from the scratch in cubeIDE (atleast not that i know of). You can still generate the files from cubemx and use registers instead of HAL
Hi, First of all thanks for a nice tutorial. I think as a safe step, we need to reset the bits for PLLP, PLLM and PLLN in PLLCFGR register to zero first. Otherwise doing OR operation would result in erroneous value for some boards. This was the case with me as I was trying to get System Clock of 100Mhz. Only after resetting those bits to zero could I make the OR operation work correctly and get desired frequency. I verified my results by running the SystemCoreClockUpdate function provided in system_stm32f4xx.c to see the value of SystemCoreClock as 100MHz (Using HSE_VALUE of 8MHz).
Hi! this video is awesome. But I have a confusion. can anyone solve it? What is the difference between these two of codes? while(!(RCC->CR & RCC_CR_HSERDY)); while((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL); Is this just way of coding or make any difference.
make sure you are using some parameter for GPIO_Config, when defining it for eg-> GPIO_Config() { something} is not a proper method but GPIO_Config(void) { something} is the correct one
@@ControllersTech after following the tutorial with the same development board, the TIM2 is so slow that when blinking an LED it is visible to they eye, with PSC=9, ARR=20
Finally, a video that makes sense, that uses the basic documentation and avoids the cryptic HAL nonsense. Thanks and keep up the good work.
been doing this for years on my channel, just saying lol
@@EdwinFairchild I have been watching your videos as well.
@@EdwinFairchild lol
Great video. You are a pioneer in STM and ARM developer resources. Really glad to see your initiative to help the next generation move to the more advanced STM32 from Arduino.
Thank you very much! I tried around with HAL, which makes clock configuration very easy, but I found out that it is so much slower than writing directly to registers for GPIO ports (factor 10 perhaps). So I decided not to use HAL for my project, but I was stuck a whole day with the clock configuration. I think the most part of it was fine, but the mistake was not to wait for the clocks to be ready like in your video. That helped and now it works! I will watch your other videos to avoid problems when moving on with the project!
Awesome video. Thanks, it helps take the scary part of bare metal coding away. I will be looking forward to the rest of the videos in this series. I presume that code written like this takes much less memory so those of us using the free version of Keil can do more within its code size limitations. Thanks again.
This video is worth gold! Helped me a lot to start from scratch without using LL or HAL :)
Your videos are so useful for embedded software students! I really appreciate your work
simply incredible, Thank you very much, Please do not forget DSI
This video took me hours to get through as I just constantly read and read about everything.
Thanks to the background music you chose, I had fun like watching a cartoon.
Again great job, I always find on your channel what I need. Datasheet + your videos are perfect combination!
It's amazing ....please make a series of these videos . Including i2C , SPI , ADC n all ....
yup.. that's the plan
@@ControllersTech can you teach how to program STM blueNRG2,, Bluetooth module.. transmit, receive and mesh network,, please
You are certainly the best when it comes to putting together videos on STM ARM. Please consider publishing a book or putting a course up on one of the MOOC providers.
IT IS A FANTASTIC VIDEO! I've finally understood how to work with all of this! Thank you very much!
That's how I first learned to program stm32 . The manual explains in terms of the registers so it's the obvious way to get started. The HAL Low Level drivers are perfect for register programming because the way the functions are written self documents your code. After a while though you'll want to use HAL drivers as they offer a good high level way to get things done.
Great Video. I was able to follow and surprisingly it worked in the first try, not a complex code I know 😅 but feels good.
Thanks again
Thank u for this vdo.
Adding voice in vdo help me to understand things more clearly. 🙂🙏
I almost feel guilty after watching this video for free and with no extra cost, thankyou
Very useful to have a first approach to this micro. Many thanks for your job and effort.
Thank you. This video is very helpful. Much practical and useful than ST tutorial videos.
Great series, I would you like to keep series.
Great work. Exactly what I was looking for. Thank you!
Great Video. After a while I even liked the music.
Thanks for the great videos! One request, please find a way to keep the ads on your website from covering the tutorial information. Also, If I resize the browser, so I can fit both my IDE and the browser side-by-side, all of the ads cover up the information as well.
Thats exactly the video i was looking for a long time. Thank you for sharing this with us 👌🏻👌🏻👌🏻
you havent been looking that well, been doing this for years on my channel lol
Thank you for this video....I'm really looking forward to the next one 👍😉
You are doinng an incredible job, Hats off to you
The HAL in stm series is only meant for those who are already good in register level programming, learners can never learn register level programming by that,... this is the video i can easily understand what the hell is happening ,thanks a lot sir
HAL is easier compared to registers. I don't think you need to know registers to program in HAL. Obviously registers gives you more control over your MCU.
@@ControllersTech yeah,my misunderstanding,but i want to learn register level programming
Yes, this is awesome! Keep it up!
I appreciate the detail, including referencing CubeMX and the programming manual. The background music was a bit distracting.
As a matter of coding style, when you have a while loop that has no body (where you are waiting for the HSE and PLL to become ready), I think it helps to use curly braces, or put the semicolon on the next line (ideally with a comment like "do nothing" or "wait until ready". A semicolon at the end of the line with the "while" keyword is easy to overlook, or looks like a function call.
👍👍 İşe yarar, ilham verici bir video. Elinize sağlık..
Awesome episode.
they have so many damn versions of this hardware good luck finding something that is exactly like yours on youtube...lol
Mannn you're amazing
Brillant tutorial absolutly love it. You did enable external oscillator which exactly doesn't exist as we can see on the board. I think you should choose Bypass clock source. What exactly running now this ARM - Bypass clock source or internal oscillator?
It works both ways, by bypassing the clock and by selecting external crystal. So either is fine.
@@ControllersTech Yeah - thanks for your answer.
Thank you very much Sir!
i do not dee "startup check box" under device in runtime envoirnment manage window in keil 5.35---why
great vid thanks! I got a question how to know following 7 steps during sys clock config
research
@@ControllersTech can you tell me where i can learn it?
Are you conecting the external crystal in the board for the microcontroller? Because i can't see it on your nucleo board
No i am not connecting any external crystal.
Great Video. But how do we configure the comparator and turn on/off an onboard LED based on the output of the comparator.
Thank you
That's a very advance topic, considering this is just the beginning of this series
Thank you a lot
what must be VOS value for stm32F401re board?
Thank you for the video.
I have doubt, that the Nucleo board used in this video no external oscillator is connected, but we have programmed the controller as an external oscillator. Please tell us how.
It have the one for the st link. It uses that..
I like your approach to non-HAL coding for setup and configuration of the MCU system and peripheral blocks. I do however miss the easy access to useful Arduino functions e.g. map(), now I know this could be hand coded but would it be possible to add an Arduino header file that contains these functions. For example I noticed in VSC-PlatformIO that when developing an ESP32 project, and probably other MCUs, an #include is automatically added, which does enable Map(), and presumably the rest of the Arduino functions, to be used; I would really like to see a video on this subject.
You can create one header file yourself consisting of all those functions..
I don't think it's necessary to make a video on that. Just google the source code of those functions and collect them at one place
Very good, I really learned a lot ... I just need a clarification on Clock Configuration in Cube MX: I am using a STM32F401RE Nucleo board and I intend to use the 8Mhz ST-Link Oscillator on the board, is this still to be configure as crystal/ceramic Resonator or as Bypass clock source ... Thank you
Either is fine.. It works with both. You can use bypass as I have seen some ST tutorials doing that
Thanks for this video. However in configure target options the xtal frequency is greyed out and I cannot change. Could you suggest How can I change the frequency. I am using STM32F401CCU6 microcontroller and I need to give 84 Mhz.
You need to enable the external HS crystal under the RCC tab.
If the void delay(uint32_t time) function does not work for you, write void delay(volatie uint32_t time) instead to avoid compiler optimization.
Thanks alot Mahiana. This was really very helpful as I was stucked here... Can u please elaborate why the issue resolved after using volatile...
@@sushivamsingh8069 As you can see in the video it properly worked without using "volatile". However we followed the steps of the video and done exactly the same thing. So what is the difference, why we need "volatile"??
We need it because our compilers differ. Let's look at the functions body: while(time--);
If it is true time is decremented. The function returns nothing, and after execution the value of time is lost.
In our case the compiler just thought: "Hey here is a function that gets a parameter, but wait!! any modification we make on that will be lost and we don't even use it in any proper conditions. Then why should I contain this parameter in that function? Let's just skip it to optimize runtime and memory."
In the video the other compiler thought it might be important so compiled it.
If we make a variable "volatile", we tell the compiler that don't make any excuses and skip, just compile it as it is.
Most of the time when you interact with hardware it is out of the compiler's scope, for example it can't see if a variable is modified by hardware, in these cases the code will only work if you use volatile variables.
@@mahianabosszuallo9726 It was really very informative from your side and I am very thankful to you...
MVP comment, saved me having to spend hours figuring out what went wrong! Thanks
wow bro :D
Hi, I have STM32F4 Discovery but I have difficulties setting up the clock. I checked the reference manuals for register differences, I checked the syntax but I didn’t find any problems. When I download the code to the Discovery Board regardless of the delay function my LEDs just lights up dim and doesn’t blink or do anything really. I had check delay but it's not work. Can you help with this ?
Debug the code. It might be blinking very fast..
Great video.
But how could i know the steps?
Every moment i have more questions…
How would i know to config the voltage regulator after enable APB?
I can i develop that mind set to figure this kind of things be myself?
I want to realy learn and not to be a copycat.
Where it is written in the data sheet or manual reference?
Please tell me the secret
I have explained things. As mentioned, the clock configuration is something very complicated in ARM, I took the help from the CUBEMX configuration.
@@ControllersTech yeah i figured it out after i watched again, sorry.
And thank you!
Thank you for this tutorial! But how can we see our actual speed to check our code right or wrong? Because I finished this tutorial and now studying your tutorial about TIMER and USART, but my clock seems to run slower as expected. Therefore, 1 second (on TIMER tutorial) on my board is relatively slower than reality, and the Hercules software can't recognize the letter 'G' from the beginning.
Your clock configuration might be wrong. Most probably the crystal frequency. Check if you have used the proper crystal frequency.
Thanks for sharing
how did you know that procedure.
excited to see this video please make one video on CAN ,FreeRTOS without HAL
In step 2, after I set the POWER ENABLE CLOCK in RCC_APB1ENR, how can I set the VOLTAGE REGULATOR because I'm using STM32F103C8 which doesn't have VOS in bit [15:14] like F446 does?
And what is the purpose of this bit?
There is another video for 103C8. Look in this playlist.
my Xtal is undefined, can't edit. Anyone can solve this problem?
How do you know for sure that the HSE is operating at 8Mhz?
Because I see in the file system_stm32f446xx.c is defining the HSE at 25Mhz
#if !defined (HSE_VALUE)
#define HSE_VALUE ((uint32_t)25000000) /*!< Default value of the External oscillator in Hz */
#endif /* HSE_VALUE */
#if !defined (HSI_VALUE)
#define HSI_VALUE ((uint32_t)16000000) /*!< Value of the Internal oscillator in Hz*/
#endif /* HSI_VALUE */
and I don't see you configuring the HSE's frequency back to 8Mhz.
"How do you know for sure that the HSE is operating at 8Mhz?"
You can check the next video in the series, where the timer is being used to setup the exact delay using this configuration.
"Because I see in the file system_stm32f446xx.c is defining the HSE at 25Mhz"
That value will be used if you use the function SystemCoreClockUpdate(), which is also defined in the system file. If you enable the HSE crystal, it will simply run at it's clock, which is 8MHz in my case.
Please arrange the playlist video with numbers 1 ,2,3... from basic to expert....
You are commenting without even looking at the playlist ?
@@ControllersTech I already checked your playlist, its seems not in order. am confused which one is first video for STM32 Budding persons.
Well this one is not an ESP32 video.
The ESP32 series doesn't have many videos yet, that's why they aren't arranged. So you just see what you are interested in.
@@ControllersTech STM32 Only..
can i use same code on stm32f407vg ? or i need to change some code ?
how to derive the programming steps for a peripheral(say GPIO) from scratch from reference manual of STM32 controllers?
Its shown in the video
Hi, I downloaded code and flash my Nucleo-F446RE board. The LED remains ON all the time, no blinking.
Further, I also commented in the program:- Pin OUTPUT and while loop (shown below). still the LED is ON. I am surprised. What could be the reason, if any one have encountered this ? thank you
// 2. Set the Pin as OUTPUT
//GPIOA->MODER |= (1
Hello Sir , firstly thank u very much for such an awasome playlist . I want to ask a question that im struggling with over 3 days and couldnt solve the problem which is when i write above codes and watch the changes of PLLCFGR register , no bit changes . I try a lot of ways and i solved that by calling the function RCC_DeInit();. But why my codes cant work withour RCC_DeInit ? And how can i solve that problem ? Best Wishes.
Maybe the reset values for your MCU are a bit different. What MCU are you using anyway ?
@@ControllersTech stm32f407vet6 - discovery board - . Sir im still trying to find a solution but i cant solve even looked to over 30-40 projects on the internet . The main problem is : even if i assign any operation - such as RCC->PLLCFGR |= (1
thank you !!!
You're welcome!
by default X3(High speed External) is not soldered, why did you enabled it when it was not there?
It uses the crystal from st link.
@@ControllersTech ohh it uses the external clock from the mcu on stlink, thanks a lot
why are you using Keil though? When CubeIDE has no code size limit
I don't know how to setup those startup files and all in cubeide..
@@ControllersTech just use a regular cube project and delete all HAL code and start with clean main
The point with this series is not to involve cubemx...
I only used it in this video for rcc setup. It's not involved in any other video in this series..
@@ControllersTech fair enough
@@EdwinFairchild one of the best if not the best course on bare metal STM programming is yours.
👌👌👌👍👌👏👌👏👌👍👌👏👌👍👌👍👌👏👌👍👌👍👌👍👌👌👌👌👌 one doubt u don't have external 8mhz crystal on your nucloe board, but how you are setting HSE BIT plz explain??!!
There is one for the st link. It is being used.
@@ControllersTechfirst thank you the quick response 👍👍👍👍👏👏👏. X1 can be used both for stlink and stm32f as HSE Is that correct, I had the doubt bcz X3 is empty in nucleo board..
8:09 Isn't it important what value is programmed first? Because when I write a value in the e.g. 4th bit of a register and then a value in the e.g. 6th bit then the first value will be overwritten or not?
That's why we perform bitwise or ( | ) and bitwise AND (&). They don't modify other bits of the register.
@@ControllersTech Hmmm, then something must be wrong in some other code from me, there I must began from the MSB what I need to set. Otherwise the lower bits were overwritten.
And I used OR and AND
@@ControllersTech But I had read that when we perform e.g.
REG |= (1
@@ControllersTech I´ve played around a little bit with bitwise operations in C (not on a microcontroller) and when I do something like that:
uint8_t test = 144; //(0b1001000)
test &= (0
interface SD card module with stm32 NO HAL waiting for your video
😔 i was hoping to skip over SPI
@@ControllersTech we will be happy if you can make one video in spi
Hlo @ControllersTech,
I am using STM32L476RGT6, I used the code as you have done in this video but I am not able to blink the led, can you please tell me what should I change to make it blink the led.
Code:
#include "stm32l476xx.h"
void SysClockConfig(void);
void GPIO_Config(void);
void Delay(uint32_t delay);
void SysClockConfig(void)
{
/* STEPS FOLLOWED
1. Enable HSE and wait for the HSE to become ready
2. Set the POWER ENABLE CLOCK and VOLTAGE REGULATOR
3. Configure the FLASH PREFETCH and the LATENCY related settings
4. Configure the PRESCALERS HCLK, PCLK1, PCLK2
5. Configure the MAIN PLL
6. Enable the PLL and wait for it to become ready
7. Select the Clock Source and wait for it to set
*/
#define PLL_M 4
#define PLL_N 80
#define PLL_P 0 // PLLP = 7
#define PLL_Q 0 // PLLQ = 2
#define PLL_R 0 // PLLR = 2
// Step 1
RCC->CR |= RCC_CR_HSEON;
while(!(RCC->CR & RCC_CR_HSERDY));
// Step 2
RCC->APB1ENR1 |= RCC_APB1ENR1_PWREN;
PWR->CR1 |= PWR_CR1_VOS;
// Step 3
FLASH->ACR |= FLASH_ACR_ICEN | FLASH_ACR_DCEN | FLASH_ACR_LATENCY_4WS;
// Step 4
RCC->CFGR |= RCC_CFGR_HPRE_DIV1; // AHB PRESCALER
RCC->CFGR |= RCC_CFGR_PPRE1_DIV1; // APB1 PRESCALER
RCC->CFGR |= RCC_CFGR_PPRE2_DIV1; // APB2 PRESCALER
// Step 5
RCC->PLLCFGR |= (PLL_M
If anyone here knows what could be the mistake, please let me know as soon as possible.
Hi sir. Where can I get the procedure to do it step by step with sequence?
Its not written anywhere.. this something you learn by programming lower end mcus..
For some peripherals like uart, i2c you can see the reference manual.
@@ControllersTech okay got it. ty sir.
I have tried to modify the registers and run it through STM32G071 but could not see the LED blinking.
Put a breakpoint inside the while loop and step over each statement. Then see if it blinks
"use defoult compiler version 5" runing..
BUT "use defoult compiler version 6" not runing...
LED is on, but does not go out.. why??
no idea
Greetings, can someone explain to me why the author put 8 MHz instead of 25 MHz when configuring the timers in the CubeMX. And how it is reflected in the values that the author writes in the registers. Thanks in advance for your help.
Because the board has 8 MHz crystal on it, not 25. And this affects your entire clock system of the MCU.
@@ControllersTech Thanks a lot, this confused me a bit, but now I understand that the HSE is fixed and cannot be changed outside of the MCU.
Hello , why do we need to configure power enable register and regulator register ? I didnt get it .
To save power, no clock is applied to most peripherals and they are disabled
On line 22 I am puzzled as to how RCC->CR |= RCC_CR_HSEON; sets the HSEON bit 16, I can see how RCC->CR |= 1
Check the definition of HSEON bit in the header file, it is 1
@@ControllersTech OK I see, thanks for that and all your very informative videos.
Great stuff, really! I have muVision 5.36 and in the Options for Target it's not possible to modify Xtal value. Any suggestion? Thanks a lot!
Try without modifying. I think it works fine
sir which pdf reader are you using?
okular
@@OUSSAMAZAIM-n3n thank you brother
Dear Sir,
Where do you set HSE Frequency ? I couldn’t find it in this code
You don't set the frequency. Based on HSE value, you set the PLLs to obtain the required clock.
@@ControllersTech But where do you know HSE value from if you don't set it up ?
I saw that HSE_VALUE is a constant defined in system_stm32f4xx.h file (default value 25 MHz), but you caculate based on HSE = 8 MHz.
It's a physical crystal on your board. I have 8 MHz so I take 8.
@@ControllersTech I got it. I think this value we can configurate. Thank you a lot.
Can we use stm32CubeIDE for register level programming?
We can't create the project from the scratch in cubeIDE (atleast not that i know of).
You can still generate the files from cubemx and use registers instead of HAL
Ok. Thanks
Hi, First of all thanks for a nice tutorial. I think as a safe step, we need to reset the bits for PLLP, PLLM and PLLN in PLLCFGR register to zero first. Otherwise doing OR operation would result in erroneous value for some boards. This was the case with me as I was trying to get System Clock of 100Mhz. Only after resetting those bits to zero could I make the OR operation work correctly and get desired frequency. I verified my results by running the SystemCoreClockUpdate function provided in system_stm32f4xx.c to see the value of SystemCoreClock as 100MHz (Using HSE_VALUE of 8MHz).
Hi
where did you find the steps to configure the clock?
Well they are not written anywhere as per my knowledge.. so i did research and made a list like that.
@@ControllersTech thanks and a really great awesome series for ppl who want to experience programming through registers.
Sir,Why did you use PWR register?
So that we can configure the voltage regulator
please share the link stm32 cube ide
You can just google it and download from the ST's website
Hi! this video is awesome. But I have a confusion. can anyone solve it?
What is the difference between these two of codes?
while(!(RCC->CR & RCC_CR_HSERDY));
while((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL);
Is this just way of coding or make any difference.
First one waits until the HDRDY bit is 1.
Second one waits until SWS is equal to SWS_PLL
@@ControllersTech Thank You very much, I appreciate Your response.
warning: no previous prototype for function 'GPIO_Config'.... What is the error?
make sure you are using some parameter for GPIO_Config, when defining it
for eg-> GPIO_Config() { something} is not a proper method
but GPIO_Config(void) { something} is the correct one
Help! My TIM2 clock is realllllyyy slow...
Dear LUKE can u explain the issue
@@ControllersTech after following the tutorial with the same development board, the TIM2 is so slow that when blinking an LED it is visible to they eye, with PSC=9, ARR=20
What's the APB1 clock ?
.