Skip to main content
Associate
April 11, 2026
Solved

How to use HRTIM for pulse width measurement

  • April 11, 2026
  • 3 replies
  • 252 views

Hello,

Can anyone tell me how to measure pulse width with the HRTIM? I need to measure a very short pulse from my time domain reflectometer. I am thinking of using the NUCLEO-H753ZI board with the STM32H753ZI MCU. All I know about measuring pulses with the HRTIM is that I need to use the external event registers and that the minimum pulse width must be >2.5 ns. Any help would be greatly appreciated.

Best answer by Michal Dudka

The HRTIM has a resolution of 2.5 ns, and the shortest measurable pulse is 2.5 ns. Since it has two "capture" channels, it should be able to measure both the pulse arrival time and the pulse width (rise time and fall time). But here it’s important to know what pulse widths and resolution you’re targeting.

The TDC-GP22 has a minimum start-stop interval of 3.5 ns (which probably wouldn’t bother you). I've tested the AS6500 (which had too low a data throughput for my purposes) and the TDC-GPX2, which turned out to contain a bug that complicates the measurement of times longer than about 500 ns (if needed, I can find a detailed description).

The solution involving the sweeping of the transmit and read pulses also works for long times. Exactly as you suggest, you generate the coarse step using a timer from the MCU and the fine step by configuring the delay line. We currently operate just such a "dual delay pulser" to compensate for photon delays in optical fibers (see the schematic). The HRTIM generates two PWM signals with selectable delay (2.5 ns step), and the NB6L295 dual delay line implements the fine delay (<2.5 ns) and also adjusts the pulse width here (two sightly shifted signals with are mixed at an AND gate).

Adjustable delay pulserAdjustable delay pulser

 

 However, I can also see a solution using the STM32F334. It’s equipped with an HRTIM with a output (!) resolution of about 220 ps. It can sweep a test pulse, and to detect the arrival time, you could theoretically use the timer input itself or an external flip-flop circuit (minimum of external components). As far as I know, the HRTIM outputs on the 334 are a bit jittery, but that shouldn’t be a problem if you can “average” across multiple measurements. I’d believe it’s possible to achieve a resolution below 1 ns with this. But as I said, it depends on what time resolution you’re aiming for. If you’re aiming for fractions of a nanosecond, then it will definitely be easier to use a ready-made TDC (like the GP22, assuming it doesn’t have the same bug as the GPX2, if that bothers you at all). 

Just to be clear, I’ve never actually built a TDC this way myself. But I’ve experimentally verified that a flip-flop circuit (MC100EP29 / EP51 ...) can distinguish whether the “clock” or “data” signal arrived first with 95% certainty within a worst-case interval of 40 ps. And that the above-mentioned procedure/schematic can generate two pulses with an adjustable interval of approximately 10 ps up to a range of ±50 ns (and likely even more).

3 replies

MM..1
Chief III
April 11, 2026

HRTIM is designed for output. Input capture isnt more precise as TIM32 maybe less.

And for measure with error less as 1% resolution is from 250ns up...

 

Michal Dudka
Lead
April 12, 2026

HRTIM has a resolution that is one-third better than that of the best timer on the fastest STM32 (the 300 MHz TIM on the STM32H7S3I8). What makes you think that HRTIM will have less accurate input capture than standard timers? Do you have any observations ?
I’m asking, among other things, because I sometimes need such precise timing measurements, but I haven’t yet had the opportunity to use HRTIM in “input capture” mode.

I typically measure time using general-purpose 32-bit timers on the STM32H725 and observe virtually no noise or jitter when measuring at maximum resolution (250 MHz).

BTW: The HRTIM outputs on the STM32H743 have practically immeasurable jitter (on a 10 GHz scope, I observed ~25 ps, and I assume that was a measurement artifact).

domenAuthor
Associate
April 12, 2026

I haven't used the HRTIM capture mode. I stumbled upon it when I was searching for a meathead to measure short pulses for my TDR. This post got me thinking that if i could use the HRTIM as a way to measure pulse width https://community.st.com/t5/stm32-mcus-products/is-there-a-possibility-to-read-the-hrtim-timer-value/td-p/591622 

Michal Dudka
Lead
April 12, 2026

Just out of curiosity, what resolution do you need for that TDR, and how do you plan to measure it? I once built a coincidence unit, and for its calibration, I tried a procedure similar to TDR and achieved a resolution of practically 10 ps (the absolute accuracy was naturally worse). And the solution was relatively simple: essentially just an adjustable delay line such as the SY89295U, MC100EP195/196, or NB6L295 to sweep the "read pulse," and a fast flip-flop (e.g., MC100EP51) to detect whether the read pulse or the measured pulse arrived first (in your case, the reflected pulse).



 

domenAuthor
Associate
April 12, 2026

I am using the LMG1020 gate driver to generate a fast rise time step and enough current into my coax. A fast window comparator is used to detect the reflections. If I am correct, in my circuit the resolution is determined by how fast I can sample the signal (because it is my bottleneck). Right now I am reading the datasheet for the TDC-GP22. It is a time-to-digital converter that allows me to measure the time when the reflection happens and its width.

Your solution is very interesting! I don't know if it would work in my application because of the length of my coaxial cable. I would need to have a timer that would trigger the delay line when it reaches its maximum delay (fine + coarse delay).

Michal Dudka
Michal DudkaBest answer
Lead
April 12, 2026

The HRTIM has a resolution of 2.5 ns, and the shortest measurable pulse is 2.5 ns. Since it has two "capture" channels, it should be able to measure both the pulse arrival time and the pulse width (rise time and fall time). But here it’s important to know what pulse widths and resolution you’re targeting.

The TDC-GP22 has a minimum start-stop interval of 3.5 ns (which probably wouldn’t bother you). I've tested the AS6500 (which had too low a data throughput for my purposes) and the TDC-GPX2, which turned out to contain a bug that complicates the measurement of times longer than about 500 ns (if needed, I can find a detailed description).

The solution involving the sweeping of the transmit and read pulses also works for long times. Exactly as you suggest, you generate the coarse step using a timer from the MCU and the fine step by configuring the delay line. We currently operate just such a "dual delay pulser" to compensate for photon delays in optical fibers (see the schematic). The HRTIM generates two PWM signals with selectable delay (2.5 ns step), and the NB6L295 dual delay line implements the fine delay (<2.5 ns) and also adjusts the pulse width here (two sightly shifted signals with are mixed at an AND gate).

Adjustable delay pulserAdjustable delay pulser

 

 However, I can also see a solution using the STM32F334. It’s equipped with an HRTIM with a output (!) resolution of about 220 ps. It can sweep a test pulse, and to detect the arrival time, you could theoretically use the timer input itself or an external flip-flop circuit (minimum of external components). As far as I know, the HRTIM outputs on the 334 are a bit jittery, but that shouldn’t be a problem if you can “average” across multiple measurements. I’d believe it’s possible to achieve a resolution below 1 ns with this. But as I said, it depends on what time resolution you’re aiming for. If you’re aiming for fractions of a nanosecond, then it will definitely be easier to use a ready-made TDC (like the GP22, assuming it doesn’t have the same bug as the GPX2, if that bothers you at all). 

Just to be clear, I’ve never actually built a TDC this way myself. But I’ve experimentally verified that a flip-flop circuit (MC100EP29 / EP51 ...) can distinguish whether the “clock” or “data” signal arrived first with 95% certainty within a worst-case interval of 40 ps. And that the above-mentioned procedure/schematic can generate two pulses with an adjustable interval of approximately 10 ps up to a range of ±50 ns (and likely even more).

MasterT
Lead II
April 12, 2026

Consider analog approach, outlined in this app. note page 5:

an-62 triangle 100psec resolution.png

 Since there is microcontroller presents, all you need is fast BJT to convert time to voltage.

H753 also  has 16-bits ADC.