Skip to main content
Associate III
September 6, 2024
Question

Timer interrupt not working

  • September 6, 2024
  • 2 replies
  • 1579 views
Hi was trying to do work with timers in stm32 when i use the timers directy like this i could set the phase voltages correctly .
kavinkumar_1-1725618668157.png
but when i use the interrupt to set the duty cyles always the phase voltages are zero
kavinkumar_0-1725618623549.png

how to dynamically set the phase voltages in the timer interrupt

 



 

    2 replies

    gbm
    Principal
    September 6, 2024

    1. Use the code insert feature instead of screen dumps.

    2. Is your timer callback ever called? Maybe you started the timer without period interrupt enabled. Use the debugger to check it.

    3. If it is called, use the debugger to check the values written to CCRx registers.

    My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice
    Associate III
    September 6, 2024

    1.Okay got it

    2. Yes the timer callback is called i could see the elec angle value being updated.

    kavinkumar_0-1725621473293.png

    kavinkumar_1-1725621485433.png

     this is my timer config where should i enable period interrupt
    3. is there a way to check the ccr registers in the live expressions?

    TDK
    Super User
    September 6, 2024

    HAL_TIM_PWM_Start does not turn on any interrupts. Use HAL_TIM_PWM_Start_IT instead if you want callbacks to happen.

     

    You can add TIM1->CCR1 to the live expressions to see it.

    "If you feel a post has answered your question, please click ""Accept as Solution""."
    Associate III
    September 6, 2024

    kavinkumar_1-1725625570412.png

    its says failed to evaluate expression

    Also i'm not using HAL_TIM_PWM_Start i'm using HAL_TIM_Base_Start_IT(&htim1) to start the interrupt @TDK 

    EDIT: tried using this 

     

     HAL_TIM_PWM_Start_IT(&htim1, TIM_CHANNEL_1);
     HAL_TIM_PWM_Start_IT(&htim1, TIM_CHANNEL_2);
     HAL_TIM_PWM_Start_IT(&htim1, TIM_CHANNEL_3);

     

     

    but still same behaviour maybe if i could see whether if the ccr values changes in the live expression would be helpful to debug