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
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.