Skip to main content
botmail2422
Associate II
June 23, 2016
Question

Timers with F4 DISCO

  • June 23, 2016
  • 1 reply
  • 497 views
Posted on June 23, 2016 at 21:54

I want to measure how long a signal is high as accurately as possible (preferably down to the microsecond). I started by triggering an EXTI interrupt one both the rising and falling edge of the signal. The EXTI handler would check if the signal is high or low. If high, it would start a timer, and if low it would end it and return how long the timer was active. I tried to implement this with SysTick but I fear it is not accurate enough. I thought about using a TIM but I don't know how to return how long the timer was running... Any advice?

    This topic has been closed for replies.

    1 reply

    Tesla DeLorean
    Guru
    June 23, 2016
    Posted on June 23, 2016 at 22:16

    For a continuous signal, I'd use PWM Input mode, otherwise Input Capture where Channel 1 and 2 were configured to timestamp opposite edges of the same signal.

    On an F4, I'd use a 32-bit timer clocking between 84 MHz and 1 MHz, and compute the delta ticks between rising and falling edges..

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..