Clock and Timers Explained with Example | STM32G474 | Timer Interrupts | Episode 4 | Part 2

Поделиться
HTML-код
  • Опубликовано: 18 ноя 2024

Комментарии • 20

  • @VaheTildian
    @VaheTildian 4 месяца назад +1

    Hello, I use a Nucleo F103RB, and I have an issue with the debugging/execution phase.
    Details of clock and choice of prescaler, Counter Period:
    At the SYSCLK I have 64 MHz, so I have 64 MHz at the HCLK and finally still 64MHz at the APB1 Timer clock, which is used by TIM4.
    I chose TIM4 in the Pinout & Configuration panel.
    I check the box for "Internal Clock", because it gives me access to the Parameter Settings, like you in the video for TIM6.
    There, I put Prescaler at 499. This way, CNT_CLK = 64MHz/(499+1) = 128 000 Hz.
    Therefore, because ARR= 0.5 * 128 000 = 64 000 < 65535 (maximum at 16bit), I put 499 as prescaler and 64 000 as the Counter Period and I activate auto-reload.
    Despite all that, and following (I assume correctly) your instructions, putting &htim4 instead of &htim6, et cetera, it does not work! :(
    I could use the debugger maybe, as you suggested in another comment, but I'm not sure what to check for.
    One detail about my timers: I don't have a simple "Activated" like you in my Cube IDE. Instead it talks to me about Slave Mode, Trigger Mode, Channel1, 2, 3, 4, et cetera...
    Please tell me what you think

  • @rameshganesan1930
    @rameshganesan1930 Год назад +1

    Good day, If possible kindly post one video for HRTIM based buck converter.
    Thank you

  • @abdulwaiz2677
    @abdulwaiz2677 6 месяцев назад +1

    Hi, Very well explained but how you find the ARR value = time based /Time Periode = 0.01176usec can you please expalin it a little bit ?

    • @vdevelop
      @vdevelop  6 месяцев назад

      It's simple mathematics. Basically we are calculating the number of counts required to generate a 0.5sec time base.
      Thus it's a simple division of time base with a width of one count period (which is the timer period).

    • @abdulwaiz2677
      @abdulwaiz2677 6 месяцев назад

      @@vdevelop thanks a lot , one more question can you please make a tutorial on high Resolution timer ?

  • @baluvolety1723
    @baluvolety1723 Год назад

    Hi, This is video is worth watching. Could you please help me out how to stop the timer interrupt. The Led is continuously blinking. I want to stop the blinking after few mins.

    • @vdevelop
      @vdevelop  Год назад

      Thanks.
      One of the simple way of doing this feature is as follows.
      1. Implement a static counter variable in the main.c
      2. Increment this variable in the period_elapsed callback function
      3. monitor value of this variable, and execute toggling action according to this value
      Recommended way
      Create a millisecond counter(global static) at the timer interrupt handler (I've not explained this in the video) and apply toggle action according to this value.
      2.

  • @fhverberne
    @fhverberne Год назад +2

    Thanks for you explanation. Just one remark for newbees like me. Your callback function is not at the correct position. User code should allways be between a USER CODE BEGIN and a corresponding USER CODE END, otherwise you'll loose your code the next time you make changes in CubeMX.
    In this situation, I would suggest:
    /* USER CODE BEGIN 4 */
    void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
    {
    HAL_GPIO_TogglePin(LED_RED_GPIO_Port, LED_RED_Pin);
    }
    /* USER CODE END 4 */

    • @vdevelop
      @vdevelop  Год назад +1

      Exactly, you're correct. I've mentioned this in the latest video i've posted.

  • @tomwawer5714
    @tomwawer5714 Год назад

    Well done thank you

    • @vdevelop
      @vdevelop  Год назад

      You're welcome.. Thanks for the appreciation ❤️

  • @sairaj8355
    @sairaj8355 Год назад

    I have done everything same but the led in not blinking
    I have Nucleo F446RE
    I have the clock frequency to 170 and rest everything is same as per video
    I didn't what the error is and how to debug it
    Hoping for positive response !

    • @vdevelop
      @vdevelop  Год назад

      Hi Sairaj, sorry for the delay in response.
      Can you please check if the program goes inside HAL_TIM_PeriodElapsedCallback (@main.c)? You can debug through the pgm by putting a breakpoint inside that function.

    • @sairaj8355
      @sairaj8355 Год назад

      @@vdevelop how to debug can you share your video of debugging

  • @negriu
    @negriu 7 месяцев назад

    How can I make it stop blinking?. Lets say I want it to blink just 10 times

    • @vdevelop
      @vdevelop  7 месяцев назад +1

      You can declare a variable (count) inside the loop and
      If count < 10

  • @ogulcanyank8982
    @ogulcanyank8982 2 года назад

    Can you share the project files with me ? I'm working on the same nucleo board. I need those files to compare with mines.

    • @vdevelop
      @vdevelop  2 года назад

      Yes. I can create a git repo and will share the link in the description.

    • @ogulcanyank8982
      @ogulcanyank8982 2 года назад

      @@vdevelop Thanks. I'm waiting for it

    • @vdevelop
      @vdevelop  2 года назад +1

      I've added the link in the video description. You can visit "04_timer" project. Sorry for the delay!