Great tutorial. I spent hours to figure out why my interrupt is not executed. Watching this video I found TIM was not initialized.Thank you WeB Learning!
Since this video is about learning. A proper prescaler setting should be (32000-1) and (1000-1). Reason; prescaler =0 will pass the clk without division prescaler =1 divide the clk by 2 prescaler =2 divide the clk by 3 ......... prescaler =(n-1) divide the clk by n Thanks.
@@Weblearning1 Don't know much about video editing on yt. But maybe you can ad this as on-screen note to the video? I have read this elsewhere too. But anyway thanks for your videos!
god I was searching every corner for an interrupt toggle or something! thanks xD but also thanks for making these! BUT I wish you explained every decision and thing too. this'd make it a lot more user friendly. telling people WHAT to do might get them be able to copy what you're doing but EXPLAINING what you're doing is a lot nicer. bascially a case of "give a man a fish bla bla" say for example instead of saying "set clock source to internal" explain each setting and option.
This is only the basic. There is SO MUCH you can do with the Timer and there are so many other video I want to make ( not enough time ) so I start with the basic and when I will get to it I will show more features.
Hi sir, could you please suggest me how to use interrupt to reset value of encoder with user button when rotate it back to the starting point. Thank you so much
if interrupt is started again while the current interrupt is going on what will happen in that case? will the code abandon current interrupt and process the new one? or will the new interrupt be put in queue?
Also a more general comment. Since you have done timers already ... A friend of mine told me he was using a timer and the dma capability of a µc to measure the RPM of a motor. Sadly he wasn't able to tell me more about it, since he hasn't used the HAL (or maybe a complete other µc). I understand the idea of DMA, but I don't get behind the ability to measure the RPM with it. I made a code that uses a EXTI to get triggered and check the timer for the counter and potential overflow (had a counter in the overflow-callback). Using this with a normal external button it was quite blocking, since the button introduced much noise since it wasn't debounced. Do you have any idea? Edit: He said the DMA saved something (i believe it was the counter of the timer) and later he used this to calc the mean. I would also ask him for more details ... But he is still sleeping ... Thanks for your videos! Stay save!
The RPM sends a square wave. The higher the frequency, the higher is the RMP. So you can use the PWM from the RPM feed into the TIM. Then use the DMA to read ever 1sec the counter of the TIM and reset the TIM again. What ever you read, that's is your RPM ( depends on the signal and timing ). Search google for: stm32 measure rpm
Thanks, helped so much. But I got a question to the interrupt handler: void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) dose not contain die Timernumber! How can I implement different interruptroutiens for ex. Timer 2 und Timer 6?? Greetings from Germany, A.
No, not hard. I've found what I was missing: void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) { if(htim->Instance == TIM3){ // Do ISR for timer 3 } if(htim->Instance == TIM6){ // Do ISR for timer 6 } } The ISR in your video will be called by overflow from every timer. Thanx for answering, greetings, A
GPIO is a physical interaction with your system, so something will happen only if you press a button. A timer will make an interrupt (or an event ) every time the counter will runout of the set value you have programmed.
Nice and well explained tutorial, i really like the STm32CUBEMXIDE which i use, can you make a video on the debugging capabilities ?, i just started to learm STM32 and the new cube mx ide is the IDE of my choice because everything is on package., thanx for this video on explaining timer with interupt.
So in this example the LED blnks every 2 seconds right? koz after 1 second toggle will set it to on then after next second it sets it to off? Or i understand the whole thing wrong ?
Has anyone ran into an issue where their timer clock frequency does not change, no matter what you change the APB bus to (using CubeMX clock configuration)? I am using a STM32H745I-DISCO board and have made sure I have included all aspects of every video I have watched on timer interrupts. Everything is working properly but no matter how I change the clock configuration, it is still the same (the values change but the LED still blinks way too fast: 240MHz even if I have the APB bus at 64MHz). Thanks in advance, I have spent a few days on and off trying to figure it out
This will work but then the beginners will not know anything even after implementing. I suggest you use HAL functions and not cube MX. At least the function calls can be explained better and which register is set etc can be explained.
@@Weblearning1 I agree. But if you could do one with the default HAL, that comes when you create a project with openSTM bench, I somehow feel is the best way to satisfy both the groups. Because I see that these CUBE HALs are quite unreadable linking to functions after functions. The default HALs directly show what registers they're programming at the same time they provide the same exact functions that we want to implement using structures. I have had my own share of tough times with no knowledge about how to go about learning. Not that I've mastered anything. But this is a time where I have learnt how to learn before which I was searching in darkness. A designer who does not know or re inventing the HALs by reading it will always be handicapped and CUBE MX supports this. It's like teaching the student 1155665 instead of do-do-sol-sol-la-la-sol in piano.He will play twinkle twinkle, but not know it. Sorry for the long comment. I just wanted to request you in short to put up tutorials with default HAL in case you have time.
Thanks for this. It's hard to make everyone happy when making such videos. Most of the viewers need this basic approach. You just need to look at how many are using Arduino language. Coming back to how you are doing things, I suggest that you will have a look at LL lib that is also part of the CubeMX. You will see that it's much more closer and simple to what you want. When I will finish with the HAL ( one day ) I might start with LL examples.
Great tutorial. I spent hours to figure out why my interrupt is not executed. Watching this video I found TIM was not initialized.Thank you WeB Learning!
You're welcome!
Same here ! was doing HAL_TIM_Base_Start(); end up realizing it should be HAL_TIM_Base_Start_IT(); after watching this video
This example triggered my interrupt only once. I had to also enable the automatic "auto-reload preload" setting as well. Solid tutorial, keep it up!
Glad it helped
Thank you so much for commenting this, i had the exact same problem!
This guy is a life saviour! I really appreciate the work you put into your educational videos.
Since this video is about learning. A proper prescaler setting should be (32000-1) and (1000-1).
Reason; prescaler =0 will pass the clk without division
prescaler =1 divide the clk by 2
prescaler =2 divide the clk by 3
.........
prescaler =(n-1) divide the clk by n
Thanks.
Of course you are correct and thanks for sharing it with everyone.
@@Weblearning1 Don't know much about video editing on yt. But maybe you can ad this as on-screen note to the video?
I have read this elsewhere too. But anyway thanks for your videos!
I from Turkey. Thanks for your lecture. Socrates bless you.
Thanks.
Exactly what I was searching for now, Thank you!
You are welcome!
god I was searching every corner for an interrupt toggle or something! thanks xD
but also thanks for making these! BUT I wish you explained every decision and thing too. this'd make it a lot more user friendly. telling people WHAT to do might get them be able to copy what you're doing but EXPLAINING what you're doing is a lot nicer. bascially a case of "give a man a fish bla bla"
say for example instead of saying "set clock source to internal" explain each setting and option.
This is only the basic. There is SO MUCH you can do with the Timer and there are so many other video I want to make ( not enough time ) so I start with the basic and when I will get to it I will show more features.
How do we know the LED was flashing on your board?👀
Could you please share the function name for the static library?
Hi sir, could you please suggest me how to use interrupt to reset value of encoder with user button when rotate it back to the starting point. Thank you so much
if interrupt is started again while the current interrupt is going on what will happen in that case?
will the code abandon current interrupt and process the new one? or will the new interrupt be put in queue?
Great video! Very simple and clear-cut!
Thanks for making those videos!
Very helpful video!!!!! Also, I have a question:why my compiler is arm-none-eabi-gcc and yours is different...
I used to use Keil. Now I only use CubeIDE.
Hello, thank you for you effort
can you please tell me, how can i change timer period while running application STM32F4 ?
thank you
Just change the registers while ruining your code.
Como se faz um calculo para a interrupção acontecer a 100uS ? Gostei do seu metodo de demostração de aula .
Please view the comments on the video below.
Also a more general comment.
Since you have done timers already ... A friend of mine told me he was using a timer and the dma capability of a µc to measure the RPM of a motor. Sadly he wasn't able to tell me more about it, since he hasn't used the HAL (or maybe a complete other µc).
I understand the idea of DMA, but I don't get behind the ability to measure the RPM with it.
I made a code that uses a EXTI to get triggered and check the timer for the counter and potential overflow (had a counter in the overflow-callback).
Using this with a normal external button it was quite blocking, since the button introduced much noise since it wasn't debounced.
Do you have any idea?
Edit: He said the DMA saved something (i believe it was the counter of the timer) and later he used this to calc the mean.
I would also ask him for more details ... But he is still sleeping ...
Thanks for your videos!
Stay save!
The RPM sends a square wave. The higher the frequency, the higher is the RMP.
So you can use the PWM from the RPM feed into the TIM. Then use the DMA to read ever 1sec the counter of the TIM and reset the TIM again. What ever you read, that's is your RPM ( depends on the signal and timing ).
Search google for: stm32 measure rpm
why prescaler is set to 32000? should it n't be 32-1?
So how can I add a pushbutton so that once pressed and released the led toggles? how can I achieve that??
You can use this video, and turn on the LED when you press the button:
th-cam.com/video/UtkszckecV8/w-d-xo.html
@@Weblearning1 I meant using a timer as well, so that once the button is released the LED flashes on and off using timers.
In the interrupt of the button, you start the timer.
Thanks, helped so much.
But I got a question to the interrupt handler:
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
dose not contain die Timernumber!
How can I implement different interruptroutiens for ex. Timer 2 und Timer 6??
Greetings from Germany,
A.
Its hard to tell without know more. Look in google for HAL_TIM_PeriodElapsedCallback, there are many answers on the ST community.
No, not hard. I've found what I was missing:
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
if(htim->Instance == TIM3){
// Do ISR for timer 3
}
if(htim->Instance == TIM6){
// Do ISR for timer 6
}
}
The ISR in your video will be called by overflow from every timer.
Thanx for answering,
greetings, A
Awesome tutorial. How does using a timer for an interrupt differ from using a GPIO interrupt? Thanks!
GPIO is a physical interaction with your system, so something will happen only if you press a button. A timer will make an interrupt (or an event ) every time the counter will runout of the set value you have programmed.
@@Weblearning1 Thanks, very helpful!
Nice and well explained tutorial, i really like the STm32CUBEMXIDE which i use, can you make a video on the debugging capabilities ?, i just started to learm STM32 and the new cube mx ide is the IDE of my choice because everything is on package., thanx for this video on explaining timer with interupt.
Thanks for the idea. I will add it to the list...
Nice sir....Thanks for updating
Please, I would like to see classes on ADC, ADC + DMA
There is one on ADC, did you see it? I still have more videos to do, it takes time...
I did not find the video
It's not market clearly, but you will find it here:
th-cam.com/video/UzvIXeRCZw0/w-d-xo.html
So in this example the LED blnks every 2 seconds right? koz after 1 second toggle will set it to on then after next second it sets it to off? Or i understand the whole thing wrong ?
The trigger is how you call it. So, blink every 1 sec ( i.e. 1Hz ), will cause the LED to change state every 1 sec.
how can i change the period y need a variable period , please help
See again the video min. 0:40 where I explain how the calculation is done.
Has anyone ran into an issue where their timer clock frequency does not change, no matter what you change the APB bus to (using CubeMX clock configuration)? I am using a STM32H745I-DISCO board and have made sure I have included all aspects of every video I have watched on timer interrupts. Everything is working properly but no matter how I change the clock configuration, it is still the same (the values change but the LED still blinks way too fast: 240MHz even if I have the APB bus at 64MHz).
Thanks in advance, I have spent a few days on and off trying to figure it out
why don't put interrupt routine on IRQHandler directly instead to "create" HAL_TIM_PeriodElapsedCallback's function??
I need to start explaining things slowly. There are so many things that can be done, so I take it one step at a time.
Great videos! thank you!
Thanks.
This will work but then the beginners will not know anything even after implementing. I suggest you use HAL functions and not cube MX. At least the function calls can be explained better and which register is set etc can be explained.
You are right, but some want to get it going with min. reading and searching and the CubeMX is the best way to do that.
@@Weblearning1 I agree. But if you could do one with the default HAL, that comes when you create a project with openSTM bench, I somehow feel is the best way to satisfy both the groups. Because I see that these CUBE HALs are quite unreadable linking to functions after functions. The default HALs directly show what registers they're programming at the same time they provide the same exact functions that we want to implement using structures. I have had my own share of tough times with no knowledge about how to go about learning. Not that I've mastered anything. But this is a time where I have learnt how to learn before which I was searching in darkness. A designer who does not know or re inventing the HALs by reading it will always be handicapped and CUBE MX supports this. It's like teaching the student 1155665 instead of do-do-sol-sol-la-la-sol in piano.He will play twinkle twinkle, but not know it. Sorry for the long comment. I just wanted to request you in short to put up tutorials with default HAL in case you have time.
Thanks for this. It's hard to make everyone happy when making such videos. Most of the viewers need this basic approach. You just need to look at how many are using Arduino language.
Coming back to how you are doing things, I suggest that you will have a look at LL lib that is also part of the CubeMX. You will see that it's much more closer and simple to what you want. When I will finish with the HAL ( one day ) I might start with LL examples.
Thanks !!!!!!!!!!!!
thanks a lot of
Thanks
Welcome
Please share link to your timer video that you mention at this instance..
th-cam.com/video/YPJlhYm5T8Y/w-d-xo.html
thank you