cancel
Showing results for 
Search instead for 
Did you mean: 

How to achieve 217ps time resolution of HRTIM STM32F334xx?

alexborysevych9
Associate II

Hey guys,

I'm trying to understand STM32F334 high resolution timer (HRTIM) in some details.

It says the timer has 217 ps resolution. But how can I achieve that in practice?

Let's say I generate PWM signal with 1MHz frequency and 500.00ns pulse width. (These are just arbitrary numbers, but lets say I have configured everything accordingly and it works). How can I get pulse width of 500.217ns (which is one more high resolution tick to add)? Is it possible?

Or equivalently, I want to get two PWM signals, but shifted by 2.17ns or 217ps, lets say.

The reason why I'm asking is "Figure 242. Counter and capture register format vs clock prescaling factor" from the manual of STM32F334xx. 

0690X000009Z284QAC.png

It essentially states, that when I multiply clock f_HRCK by factor 2, I lose one bit of precision. So the actual PWM time precision stays the same regardless of the f_HRCK.

Or following this table:

0690X000009Z28EQAS.png

If I have configured HRTIM with maximum equivalent frequency of 4.608 GHz (CKPSC = 000), then I can specify period and compare register only in values multiple by 32, since all 5 LSB bits became disabled/not significant (according to Figure 242). As a result I still have 217ps * 32 = 6.95ns effective time resolution, as it is without frequency multiplication of the clock (when CKPSC = 101). So I cant use the advantages of this high frequency clock and claimed 217ps resolution.

Am I missing something?

5 REPLIES 5

Of course the timer does not run at 4.6GHz, so you can't expect the synchronous stuff (counters, captures) to run at 217ps resolution.

All the magic is in delay lines with selectable taps at the outputs. The HRTIM is very complex, as it wants to cater for various options, and that ST did not want to tell out aloud the "delay line" word for marketing reasons, and tries to mimic a timer running at much higher speed, significantly hurts the legibility of the documentation.

JW

Hi waclawek.jan,

Thank you so much for your reply and your attention to my question.

Have you ever tried HRTIM by yourself?

Since it seems like it is impossible to observe 217ps resolution directly, are there any other cues which can indicate a presence of HRTIM and its high-precision capabilities? Because it seems like it is just an another timer, with maybe nice and useful architecture features, but really without high time resolution, at least not detectable externally.

> Have you ever tried HRTIM by yourself?

No.

> Since it seems like it is impossible to observe 217ps resolution directly,

Why would that be impossible? Modern oscilloscopes have several gigabytes analog bandwidth and tens of gigasamples per second, with appropriate probes of course.

JW

I indeed have such a scope to be able to see the time resolution beyond 1ns.

The problem is that I cant program HRTIM to get this.

Vincent Onde
ST Employee

​Hi,

I suggest to start with the demo code included in the STM32Cube_FW_F3 library. There are some simple demos in the STM32F3348-Discovery Examples (eg HRTIM_BasicPWM). There is also a HRTIM_Snippets version if you prefer directly with registers (you'll see you don't need to write many registers to get a basic PWM with 217ps resolution). This is documented in the HRTIMER cookbook (AN4539).

Two ways to clearly see the high-resolution:

  • using two PWM outputs, one with constant duty cycle and the other continuously adjusting the duty cycle with 217ps steps (let's say from 1 to 32, in a loop). Using infinite persistence, you'll see the high-resolution steps.
  • With a similar principle, using a low-pass filter. This is done in the STM32Cube_FW_F3_V1.10.0\Projects\STM32F3348-Discovery\Demonstrations software, and described in the AN4885 (section 1.4.7 Triangle waveform generation).

Best regards

Vincent