Skip to main content
Microman
Associate III
October 8, 2019
Solved

Measuring exact time between to pulses

  • October 8, 2019
  • 2 replies
  • 2692 views

Hi all,

To be hontest, I am a beginner when it comes to timer and capture hardware. Maybe someone can help me figuring out what the best way is how I can measure the time between two separate impules i get on two separate lines. Accuracy shall be very high.

First input: some master clock pulse (1kHz) Second Input: some delayed clock pulse with high level for a few microseconds. I need to measure the time between the first pulse and the second.

First thought, use two synced timers, capture two values and calculate the difference between them. Second thought, reset a timer by the 1kHz reference pulse and capture to the timer counter register when the second pulse on a different pin is comming in.

Any ideas how to configure the STM32H743 for this?

Thanks a lot!

This topic has been closed for replies.
Best answer by Tesla DeLorean

TI has a chip that does this sort of A-B timing very accurately.

On the STM32H7 use a 32-bit TIM, TIM2 or TIM5 should suffice, clock at maximal speed/length, ie Prescaler = 0, Period = 0xFFFFFFFF

Program two Channels in Input Capture mode, say CH1 and CH2 such that CCR1=CNT and CCR2=CNT latch on the incident pulses. Where CNT increments at TIMCLK

You can then subtract the two values to arrive at a delta measurement with a clock granularity matching the TIMCLK source. I think they clock at 100 MHz, so 10 ns units.

2 replies

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
October 8, 2019

TI has a chip that does this sort of A-B timing very accurately.

On the STM32H7 use a 32-bit TIM, TIM2 or TIM5 should suffice, clock at maximal speed/length, ie Prescaler = 0, Period = 0xFFFFFFFF

Program two Channels in Input Capture mode, say CH1 and CH2 such that CCR1=CNT and CCR2=CNT latch on the incident pulses. Where CNT increments at TIMCLK

You can then subtract the two values to arrive at a delta measurement with a clock granularity matching the TIMCLK source. I think they clock at 100 MHz, so 10 ns units.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Microman
MicromanAuthor
Associate III
October 9, 2019

Just tried it this way and it gives me reasonable results, down do 8,33ns (1 / 120MHz max. timer clock). Thanks a lot!