2025-12-01 6:43 AM - last edited on 2025-12-02 10:08 AM by Imen.D
Hi everyone,
I am working on an STM32G4 project using the HRTIM1 peripheral.
My goal is to generate a burst of exactly 3 PWM pulses on Timer A and Timer B simultaneously, triggered by an External Event (Sync Input / EEV).
The Goal:
System waits for an external trigger (e.g., from TIM3 via TRGO or physical pin).
Upon trigger, HRTIM Timer A and Timer B start.
They output exactly 3 PWM cycles.
They stop and wait for the next trigger (Single-Shot Retriggerable).
The Configuration:
I am using STM32CubeIDE and HAL, but I also tried direct register access.
Master Timer: Acts as a dummy/pass-through for synchronization.
Timer A & B:
Mode: Single-Shot Retriggerable.
Prescaler: Div1.
Period: 1000 ticks.
Repetition Counter: 2 (Targeting $N+1 = 3$ pulses).
Start on Sync: Enabled.
Reset on Sync: Enabled.
Preload Enable: Disabled (To force immediate register update).
The Problem:
Despite setting REPxR = 2, I consistently see only 1 pulse on the scope when the trigger arrives. It seems the timer resets and starts, but the Repetition Counter value is ignored or treated as 0 for the first run.
Any help will be appreciated
Thank you
2025-12-02 10:06 AM - edited 2025-12-02 10:06 AM
Hello @GiovanniL
Did you set the repetition counter before enabling the timer?
After configuring the HRTIM and before enabling it or waiting for the external trigger, generate an update event to ensure the repetition counter is loaded.
Check the repetition counter value during operation through the HRTIM debug registers.
STM32G4-WDG_TIMERS-High_Resolution_Timer_HRTIM.pdf
AN4539 HRTIM cookbook - Application note