cancel
Showing results for 
Search instead for 
Did you mean: 

PWM input output drift

chrkaras
Associate III

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

0 REPLIES 0