HAL #10: HowTo Timer with Interrupt

แชร์
ฝัง

ความคิดเห็น • 66

  • @Grze9898
    @Grze9898 4 ปีที่แล้ว +1

    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!

    • @Weblearning1
      @Weblearning1  4 ปีที่แล้ว

      You're welcome!

    • @nicholasng8291
      @nicholasng8291 2 ปีที่แล้ว

      Same here ! was doing HAL_TIM_Base_Start(); end up realizing it should be HAL_TIM_Base_Start_IT(); after watching this video

  • @ryanfleming2448
    @ryanfleming2448 4 ปีที่แล้ว +1

    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!

    • @Weblearning1
      @Weblearning1  4 ปีที่แล้ว

      Glad it helped

    • @jelmervd2l
      @jelmervd2l 4 ปีที่แล้ว

      Thank you so much for commenting this, i had the exact same problem!

  • @trungnguyen-xuan7942
    @trungnguyen-xuan7942 4 ปีที่แล้ว +2

    This guy is a life saviour! I really appreciate the work you put into your educational videos.

  • @malgailany
    @malgailany 5 ปีที่แล้ว +19

    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
      @Weblearning1  5 ปีที่แล้ว +1

      Of course you are correct and thanks for sharing it with everyone.

    • @Stimmenhotel
      @Stimmenhotel 4 ปีที่แล้ว +1

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

  • @sokrates2099
    @sokrates2099 4 ปีที่แล้ว

    I from Turkey. Thanks for your lecture. Socrates bless you.

  • @andrelarsen7317
    @andrelarsen7317 4 ปีที่แล้ว +1

    Exactly what I was searching for now, Thank you!

  • @ameliabuns4058
    @ameliabuns4058 4 ปีที่แล้ว +5

    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.

    • @Weblearning1
      @Weblearning1  4 ปีที่แล้ว

      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.

  • @GrimReaper-bv4tg
    @GrimReaper-bv4tg 8 หลายเดือนก่อน +1

    How do we know the LED was flashing on your board?👀

  • @talashganvir4144
    @talashganvir4144 9 หลายเดือนก่อน

    Could you please share the function name for the static library?

  • @quyenoan5463
    @quyenoan5463 2 ปีที่แล้ว

    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

  • @sabzimatic
    @sabzimatic 2 ปีที่แล้ว

    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?

  • @abdelaleem4026
    @abdelaleem4026 4 ปีที่แล้ว

    Great video! Very simple and clear-cut!

  • @TheKrambambuli
    @TheKrambambuli 5 ปีที่แล้ว +2

    Thanks for making those videos!

  • @王耀辉-t1r
    @王耀辉-t1r 3 ปีที่แล้ว +1

    Very helpful video!!!!! Also, I have a question:why my compiler is arm-none-eabi-gcc and yours is different...

    • @Weblearning1
      @Weblearning1  2 ปีที่แล้ว

      I used to use Keil. Now I only use CubeIDE.

  • @Yassin_Ro
    @Yassin_Ro 4 ปีที่แล้ว +1

    Hello, thank you for you effort
    can you please tell me, how can i change timer period while running application STM32F4 ?
    thank you

    • @Weblearning1
      @Weblearning1  4 ปีที่แล้ว +1

      Just change the registers while ruining your code.

  • @luizazeredo5197
    @luizazeredo5197 4 ปีที่แล้ว

    Como se faz um calculo para a interrupção acontecer a 100uS ? Gostei do seu metodo de demostração de aula .

    • @Weblearning1
      @Weblearning1  4 ปีที่แล้ว

      Please view the comments on the video below.

  • @Stimmenhotel
    @Stimmenhotel 4 ปีที่แล้ว +1

    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!

    • @Weblearning1
      @Weblearning1  3 ปีที่แล้ว +1

      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

  • @yashkanani4858
    @yashkanani4858 ปีที่แล้ว

    why prescaler is set to 32000? should it n't be 32-1?

  • @joeyDrivez
    @joeyDrivez 2 ปีที่แล้ว

    So how can I add a pushbutton so that once pressed and released the led toggles? how can I achieve that??

    • @Weblearning1
      @Weblearning1  2 ปีที่แล้ว

      You can use this video, and turn on the LED when you press the button:
      th-cam.com/video/UtkszckecV8/w-d-xo.html

    • @joeyDrivez
      @joeyDrivez 2 ปีที่แล้ว

      @@Weblearning1 I meant using a timer as well, so that once the button is released the LED flashes on and off using timers.

    • @Weblearning1
      @Weblearning1  2 ปีที่แล้ว

      In the interrupt of the button, you start the timer.

  • @DB--lv6tt
    @DB--lv6tt 4 ปีที่แล้ว

    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.

    • @Weblearning1
      @Weblearning1  4 ปีที่แล้ว

      Its hard to tell without know more. Look in google for HAL_TIM_PeriodElapsedCallback, there are many answers on the ST community.

    • @DB--lv6tt
      @DB--lv6tt 4 ปีที่แล้ว +3

      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

  • @nickm2517
    @nickm2517 5 ปีที่แล้ว +1

    Awesome tutorial. How does using a timer for an interrupt differ from using a GPIO interrupt? Thanks!

    • @Weblearning1
      @Weblearning1  5 ปีที่แล้ว +1

      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.

    • @nickm2517
      @nickm2517 5 ปีที่แล้ว +1

      @@Weblearning1 Thanks, very helpful!

  • @ronaldhofman1726
    @ronaldhofman1726 5 ปีที่แล้ว +1

    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.

    • @Weblearning1
      @Weblearning1  5 ปีที่แล้ว

      Thanks for the idea. I will add it to the list...

  • @chandruarul7941
    @chandruarul7941 5 ปีที่แล้ว +1

    Nice sir....Thanks for updating

  • @williamtaisonsarassa4761
    @williamtaisonsarassa4761 5 ปีที่แล้ว +1

    Please, I would like to see classes on ADC, ADC + DMA

    • @Weblearning1
      @Weblearning1  5 ปีที่แล้ว

      There is one on ADC, did you see it? I still have more videos to do, it takes time...

    • @williamtaisonsarassa4761
      @williamtaisonsarassa4761 5 ปีที่แล้ว

      I did not find the video

    • @Weblearning1
      @Weblearning1  5 ปีที่แล้ว

      It's not market clearly, but you will find it here:
      th-cam.com/video/UzvIXeRCZw0/w-d-xo.html

  • @faiezfatnassi818
    @faiezfatnassi818 5 ปีที่แล้ว

    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 ?

    • @Weblearning1
      @Weblearning1  5 ปีที่แล้ว

      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.

  • @fabiorodriguez8258
    @fabiorodriguez8258 4 ปีที่แล้ว +1

    how can i change the period y need a variable period , please help

    • @Weblearning1
      @Weblearning1  4 ปีที่แล้ว

      See again the video min. 0:40 where I explain how the calculation is done.

  • @bensvetlov7274
    @bensvetlov7274 3 ปีที่แล้ว

    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

  • @m.dasvirgenss
    @m.dasvirgenss 5 ปีที่แล้ว

    why don't put interrupt routine on IRQHandler directly instead to "create" HAL_TIM_PeriodElapsedCallback's function??

    • @Weblearning1
      @Weblearning1  5 ปีที่แล้ว

      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.

  • @PauloSantos-cv1bi
    @PauloSantos-cv1bi 5 ปีที่แล้ว +1

    Great videos! thank you!

  • @subramaniantr2091
    @subramaniantr2091 4 ปีที่แล้ว

    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
      @Weblearning1  4 ปีที่แล้ว

      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.

    • @subramaniantr2091
      @subramaniantr2091 4 ปีที่แล้ว

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

    • @Weblearning1
      @Weblearning1  4 ปีที่แล้ว

      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.

  • @arielcarmeli1696
    @arielcarmeli1696 3 ปีที่แล้ว +1

    Thanks !!!!!!!!!!!!

  • @lonny_breaux
    @lonny_breaux ปีที่แล้ว +1

    thanks a lot of

  • @ardaklc7617
    @ardaklc7617 4 ปีที่แล้ว

    Thanks

  • @sabzimatic
    @sabzimatic 2 ปีที่แล้ว

    Please share link to your timer video that you mention at this instance..
    th-cam.com/video/YPJlhYm5T8Y/w-d-xo.html
    thank you