cancel
Showing results for 
Search instead for 
Did you mean: 

Measuring exact time between to pulses

Microman
Associate III

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!

1 ACCEPTED SOLUTION

Accepted Solutions

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
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

2 REPLIES 2

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
Up vote any posts that you find helpful, it shows what's working..
Microman
Associate III

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