2025-11-21 12:55 AM
Hi, I am trying to reset HRTIM on an external event using TIM1 TRGO as a reset event. I am trying to make a single pulse every 200ms (5Hz) because I want to make a single puls test. However, I also need a high resolution so I can vary the on time and blanking time precisely, which is way I want to use the HRTIM.
I have trouble getting the HRTIM to reset however, and I dont understand why. I am running the clock at 100Mhz and have set the TIM1 PSC to 9999 and ARR to 19999 to get the 5hz. I have also enabled the MSM(master/slave mode) and set the TRGO to RESET. In the HRTIM I have enabled EEV1 as source 3(TIM1_TRGO). Timer A is configured as a retriggerable single-shot mode where the reset trigger source is set so the timer counter reset is upon EEV1.
The HRTIM clock is divided by 4 and the period is 50000. And I have compare unit 1 set as 49000 and compare unit 2 as 49500. The output polarity is set to active low and set and source selection is CMP1 and CMP2 respectively. Later I would also like to use Timer B in similar manner, but I would like to get the single-shot mode working first.
I have enabled
HAL_TIM_Base_Start(&htim1);
and HAL_HRTIM_WaveformOutputStart(&hhrtim1, HRTIM_OUTPUT_TA1); // Enable the generation of the waveform signal on the designated outputHAL_HRTIM_WaveformCounterStart(&hhrtim1, HRTIM_TIMERID_TIMER_A); // Start the counter of the Timer A operating in waveform mode
Is there something I am missing here?
Thanks, Magnus
Solved! Go to Solution.
2025-12-15 5:49 AM
hello @MagnusNTNU
I am sorry that you could not achieve the desired results with low frequencies.
I attempted to replicate your case on the STM32G474, as you did not specify which STM32G4 device you are using.
I will attach the project so that you can use it as a reference.
The configuration generates a frequency of approximately 200 Hz, which you can monitor on the PA8 pin.
However, as I mentioned, if you want to keep the DDL activated, you are restricted by a minimum frequency.
Hope that answered your question, please tell me
Gyessine
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.
2025-11-24 5:06 AM
hello @MagnusNTNU
Honestly, I am not sure if your case is achievable.
Well, since you did not specify which STM32G4 product you are using, if you refer to the STM32G474 reference manual per example, table 231, you will find that the minimum frequency achievable when using the 111 combination in the CKPSC bits is 0.65 kHz, which is far from the desired 5 Hz.
I tried to replicate your use case on an STM32G474, and the best I achieved was a period of nearly 7ms before the timer failed to generate an output.
I am going to attach the project; maybe it will help you.
Hope that helps.
Gyessine
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.
2025-11-24 6:13 AM
Thanks for the reply.
But here you are not externally triggering the HRTIM by using TIM1 TRGO. But what you/reference manual are saying is that it is only possible to trigger HRTIM with TIM1 TRGO if the output frequency is higher than 0.65kHz?
Magnus
2025-11-25 12:10 AM
hello @MagnusNTNU
Reaching these low ranges of frequencies with HRTIM is not dependent of how you trigger the timer. It is related to whether the digital locked loop (DLL) is enabled or not. As I mentioned, I do not think it is achievable (with the DLL enabled). However, if you deactivate the digital locked loop, you can reach frequencies of 5Hz.
Hope that helps you
Gyessine
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.
2025-12-15 4:47 AM
Hello @MagnusNTNU
just asking about any feedback, Does the problem still persist, or has it been resolved?
Gyessine
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.
2025-12-15 5:11 AM
Hello @Gyessine
I have not been able to make it work with the low frequencies I desired. However, I must say I haven't tried very hard either.
I was wondering if you deactivate the delay locked loop you also deactivate the opportunity to use the HRTIM with as high resolution as well right?
Magnus
2025-12-15 5:49 AM
hello @MagnusNTNU
I am sorry that you could not achieve the desired results with low frequencies.
I attempted to replicate your case on the STM32G474, as you did not specify which STM32G4 device you are using.
I will attach the project so that you can use it as a reference.
The configuration generates a frequency of approximately 200 Hz, which you can monitor on the PA8 pin.
However, as I mentioned, if you want to keep the DDL activated, you are restricted by a minimum frequency.
Hope that answered your question, please tell me
Gyessine
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.
2025-12-15 6:03 AM
Thanks for the help anyways. I am using the STM32G474 as well so I will take a look the project. As you mention, I don't think it it possible to have a 5Hz signal, while still be able to use the HRTIM very low resolution at the same time.
Magnus
2025-12-19 7:48 AM
hello @MagnusNTNU
Great, waiting for your feedback and if you feel that your When your question is answered, please close this topic by choosing "Accept as solution"
BR
Gyessine
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.
2025-12-19 7:52 AM
From what you describe, the configuration itself mostly makes sense, but the problem is likely that TIM1 TRGO is set to RESET instead of UPDATE, with RESET you don’t get a periodic trigger, so HRTIM only sees one event (or none at all). In practice, switching TRGO to UPDATE, keeping EEV1 unfiltered with the correct polarity, and starting the HRTIM timer before TIM1 usually fixes this. MSM isn’t really needed here, and once the reset event is actually reaching HRTIM, the single-shot behavior works as expected.