Skip to main content
Graduate
April 1, 2025
Question

STM32F407IET Timer Gated Mode

  • April 1, 2025
  • 6 replies
  • 740 views

Hello, 

I am using the STM32F407IET in one of my projects and I have timer 1 set us as follows below 

Jm3_0-1743517295652.png

Jm3_1-1743517313084.png

Jm3_2-1743517350952.png

currently my channel 1 is used to record the positive rises on a incoming pulse signal and what I want to do is use the gated mode to be able to tell me when the pulse is high this way I should be able to calculate duty cycle. the issue that I am currently facing is the gated count can elapse before my DMA interrupt flags so I'm struggling to measure anything with over ~5% duty cycle. is there a way on this timer to throw an interrupt when the count has elapsed? 

for example I have another timer set up to so when the count reaches the end of its counting period it throws an interrupt so I can set a bunch of flags every second and that's using the global interrupt but for some reason timer 1 doesn't have a global interrupt and I don't know how to make it interrupt from the timer. 

if you need any more information please let me know and hopefully that makes sense. 

Thank you

 

    This topic has been closed for replies.

    6 replies

    Super User
    April 1, 2025

    I have no idea whatsoever what do you want to achieve. Try to draw a timing diagram.

    JW

    Jm3Author
    Graduate
    April 2, 2025

    All I want to be able to do is have an interrupt when the count on timer 1 elapses?

    Super User
    April 3, 2025

    If you want interrupt when TIMx_CNT reaches TIMx_ARR, that's Update event, so what you want is Update interrupt.

    JW

    Jm3Author
    Graduate
    April 4, 2025

    Yes that's what I thought, so for my configuration now I have my TIM1_ARR set to 65535 and the NVIC TIM1 Update enabled 

    Jm3_0-1743760781246.png

    Jm3_1-1743760795982.png

    I assumed then that once TIM1_CNT reached TIM1_ARR it would trigger a interrupt so I went into the interrupt code and put a breakpoint here

    Jm3_2-1743761120814.png

    but it never stops on it even though it will stop on other interrupts. 

    I'm not sure if maybe I have my configuration wrong but I'm just confused as to why its not triggering. 

    Thank you

    Super User
    April 5, 2025

    Well, I don't know. I don't use Cube/CubeMX/CubeHAL, and all I can offer is a "interrupt-doesn't-fire" checklist, but that expects register-level debugging.

    JW

    Explorer
    April 5, 2025
    Jm3Author
    Graduate
    April 7, 2025

    Thank you for your help, I relalised I was not initializing the timer 1 interrupt.