Skip to main content
chrkaras
Associate II
May 6, 2026
Question

PWM input output drift

  • May 6, 2026
  • 1 reply
  • 150 views

Hello everyone,

I have an NUCLEO-H755I-Q with the following setup;

i) A 50Hz PWM input pulse goes to HTIM1 in PWM input mode with DMA enabled in channel 2 so the moment CCR2 has captured some data they can be transferred,

ii) HRTIMCHA2 with CMP1 enabled and; Period 40000 (the timer runs at 2MHz), Preload enabled, Channel A Update resets the timer counter, Set Source the period event and Reset Source the CMP1 event.

So what I basically do is simply capture a PWM, make a DMA transfer in the negative edge of the input pulse to the shadow register of the HRTIMCHA2 CMP1 and forward it as output. So, theoretically, the only delay that should be added is only by how much time the hardware needs to do its things. And that, theoretically should be a constant value, since all the work is expected to be done by the HRTIMCHA2. I tried to measure the phase shift the input and output of H7 have by hooking them both in; 1) to a NUCLEO-G474RE and 2) with an oscilloscope. The G4 was just configured to use two HTIMs in PWM Input mode and an interrupt was triggered in the positive edge to get a timestamp of when the pulses arrived and what CCR1 and CCR2 did capture.

In both ways I observed the same thing; The output pulse drifts in respect of the input pulse. And while this is normal for an oscilloscope with only one trigger for two channels, I can't understand why this is happening also in the G4. I mean I imported the data to spread sheet and the difference between the timestamps of the input and output of H7 is always increasing, while the . Is this happening because the G4 and H7 have different clocks and while they say it runs in 8MHz for example it actually runs faster/slower and this creates an almost linear phase shift, as the image I attached shows? Is it something else?

I know if I add an External Event on the HRTIM of the H7 it will fix the problem. I just want to get some opinions on why does it drift if I don't add a "synchronization method" in this case.

Thanks in advance for your time

1 reply

ST Technical Moderator
September 14, 2026

Hi ​@chrkaras 

If you are still facing the issue, could you please provide the clock tree configuration for TIM1 and HRTIM on the H755I-Q. Ideally, attach the project used to reproduce the behavior

To give better visibility on the answered topics, please click on "Best answer" on the reply which solved your issue or answered your question.Best regards,FBL