Is there a possibility to read the HRTIM timer value ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-09-18 02:33 AM
Hello,
I'm planning to use the STM32G474 to read a pulse width. This width is a delay value in nanoseconds.
I'm wondering if there is any possibility to use the High resolution timer (HRTIM) for that operation.
I would use the events to trigger a rising (set the timer) & falling edge (reset the timer) and then read the value to get the width (delay) of my pulse signal.
If anyone has an idea, it could be helpful :)
Kind regards,
Chris
Solved! Go to Solution.
- Labels:
-
HRTIM
-
STM32G4 Series
-
TIM
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-09-20 01:22 AM
Hello @Bubbles,
Let me resume my configuration to make everything clear.
Goal: measure the width of an input pulse that is some nanoseconds (between 1ns & 5ns).
Setup:
- I'm using the HRTIM Timer A with a clock at [f(hrtim) x 32] = 5.44GHz
- I'm using the HRTIM Capture for the measurement of the width
- EEV1 is triggered on a rising edge on the input pulse
- EEV2 is triggered on a falling edge on the input pulse
- The Counter of the timer A is reset every time by EEV1
- The Capture is triggered every time by EEV2
With such setup, I'm resetting the counter when the pulse start and reading the value of it when the pulse stops. That way I'm able to get the width of the pulse.
The only issue is that the External Event Configuration frequency is set to the HRTIM frequency which is 170MHz max in my case. So that means that the EEV cannot follow a signal below 5.88ns (and even higher than 5.88ns it is not that accurate, practically it needs min 10ns of pulse width) and in my case I can have some pulses that are about some nanoseconds...
I don't think that the EExFAST can change the speed of the triggering of the External Event, it will just reduce the delay of it.
Hopefully you do understand my configuration better now and maybe have an idea of any solution to it.
Kr,
Sidius
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-09-18 04:45 AM
Hello @Sidius,
I believe you are looking for a "Capture" mode use. I don't think there are lots of examples of HRTIM configured in Capture mode, but you can refer to AN4013, AN4539 and also try to configure the HRTIMer in CubeMX.
It's also quite clearly described in the RM440.
BR,
J
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-09-18 09:30 AM - edited ‎2023-09-18 09:32 AM
Use any regular timer, same resolution as HRTIM but much easier to program.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-09-19 03:39 AM
Hello @Bubbles,
I found out that it is possible to configure the "Capture" mode to try to get the width of my delay (the pulse).
I'm currently using an event to reset the counter when the PWM delay is rising and the capture when the PWM delay is falling.
Unfortunately due to the event frequency being equal to my main frequency and not the high resolution frequency, I'm not able to get a high resolution value (for example if I go close to the nanosecond).
Is there any solution to still use the capture mode but in a more accurate way ?
KR,
Sidius
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-09-19 03:40 AM
The STM32G474 has not any normal timer with such high resolution as the HRTIM...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-09-20 12:23 AM
Hello @Sidius,
I'm not completely sure to understand your configuration, but it sound like you need to enable the fast asynchronous path EExFAST = 1 of the event. The event conditioning is then not possible, but it should be able to take advantage of the HR clock.
Look at "27.3.8 External events global conditioning" in the RM440.
BR,
J
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-09-20 01:22 AM
Hello @Bubbles,
Let me resume my configuration to make everything clear.
Goal: measure the width of an input pulse that is some nanoseconds (between 1ns & 5ns).
Setup:
- I'm using the HRTIM Timer A with a clock at [f(hrtim) x 32] = 5.44GHz
- I'm using the HRTIM Capture for the measurement of the width
- EEV1 is triggered on a rising edge on the input pulse
- EEV2 is triggered on a falling edge on the input pulse
- The Counter of the timer A is reset every time by EEV1
- The Capture is triggered every time by EEV2
With such setup, I'm resetting the counter when the pulse start and reading the value of it when the pulse stops. That way I'm able to get the width of the pulse.
The only issue is that the External Event Configuration frequency is set to the HRTIM frequency which is 170MHz max in my case. So that means that the EEV cannot follow a signal below 5.88ns (and even higher than 5.88ns it is not that accurate, practically it needs min 10ns of pulse width) and in my case I can have some pulses that are about some nanoseconds...
I don't think that the EExFAST can change the speed of the triggering of the External Event, it will just reduce the delay of it.
Hopefully you do understand my configuration better now and maybe have an idea of any solution to it.
Kr,
Sidius
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-09-20 04:28 AM
Hello @Sidius,
I understand now.
unfortunately you are right, the fHRTIM is the limit for event capture.
If the signal you measure is periodical, you can try to use HRTIM to generate own signal, gradually tune the delay to match it and then devise the period from the HRTIM settings. But I understand this is way too cumbersome and not generic enough.
BR,
J
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-09-20 04:39 AM
>measure the width of an input pulse that is some nanoseconds (between 1ns & 5ns)
maybe by using a fpga and setting up something like a gate delay line ...
(this would be similar to the way, the HRTIM is working )
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-09-20 04:58 AM
...better read manual, to see, whats possible at all:
P. 139