Hi,
I'm trying to synchronize my ePWM with an incoming square-wave signal on an f28335. However, I want to have a negative phase shift on my output because there is a small delay on my synchronization signal.
So, what I try to do is this (sorry for the bad drawing):
But the output I get is this (the yellow is ePWM1a, the green is ePWM1b and the blue is the synchronization signal):
The relevant code I use for the ePWM:
EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Count up/down
EPwm1Regs.TBCTL.bit.PHSEN = TB_ENABLE; // Enable phase loading
EPwm1Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_IN; // Synchronize with EPWMSYNCI
EPwm1Regs.TBPHS.half.TBPHS = 0x0100; // Phase is 0
EPwm1Regs.TBCTL.bit.PHSDIR = 1; // Count up after sync
EPwm1Regs.TBCTR = 0x0000; // Clear counter
When I change PHSDIR to 0 it works, as shown in the picture below:
So it must have something to do with the phase direction. The TBPRD I use is 0x03A9.
Thanks in advance!
Christian
EDIT: Oops. Forgot the action settings for the ePWM. It is:
EPwm1Regs.AQCTLA.bit.ZRO = AQ_SET; // Set ePWM1A at zero
EPwm1Regs.AQCTLA.bit.PRD = AQ_CLEAR; // Clear ePWM1A TBPRD
EPwm1Regs.AQCTLB.bit.ZRO = AQ_SET; // Set ePWM1B at zero
EPwm1Regs.AQCTLB.bit.PRD = AQ_CLEAR; // Clear ePWM1A at TBPRD



