2019-07-23 04:27 PM
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.
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:
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?
2019-07-25 03:45 AM
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
2019-07-28 07:55 PM
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.
2019-07-28 09:59 PM
> 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
2019-07-29 10:21 AM
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.
2019-08-29 06:54 AM
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:
Best regards
Vincent