This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28035: PWM synchronization issue

Part Number: TMS320F28035


Hi, I'm trying to use SWFSYNC (Software Forced Synchronization Pulse) to do synchronization between ePWM1, ePWM2, ePWM3.

In the datasheet it says that

SWFSYNC is valid (operates) only when EPWMxSYNCI is selected by SYNCOSEL = 00.

1. If I use "EPwm2Regs.TBCTL.bit.SWFSYNC=1;" to force EPwm2Regs.TBCTR=EPwm2Regs.TBPHS.half.TBPHS, I will have to configure SYNCOSEL of ePWM1 or ePWM2 to be 00? It makes no sense to configure EPwm2Regs.TBCTL.bit.SYNCOSEL to be 00 because the sync source of epwm2 is determined by epwm1.

2. Moreover, it seems that no matter what SYNCOSEL is configured for ePWM1 and ePWM2, the SWFSYNC can always force EPwm2Regs.TBCTR=EPwm2Regs.TBPHS.half.TBPHS.

__asm(" NOP");                                            //EPwm1Regs.TBCTR and EPwm2Regs.TBCTR are both 0x20;
EPwm2Regs.TBCTL.bit.SWFSYNC=1;
__asm(" NOP");
__asm(" NOP");
__asm(" NOP");
__asm(" NOP");
__asm(" NOP");
__asm(" NOP");
__asm(" NOP");
__asm(" NOP");                                          //EPwm1Regs.TBCTR=0x53, EPwm2Regs.TBCTR=0x02, which means that EPwm2Regs.TBCTL.bit.SWFSYNC takes                                                                         effect

3. I add __asm(" NOP");  because if I single step through EPwm2Regs.TBCTL.bit.SWFSYNC=1; EPwm1Regs.TBCTR and EPwm2Regs.TBCTR are the same, means that EPwm2Regs.TBCTL.bit.SWFSYNC does not take effect, why?

  • Howard,

    To sync ePWM1 and ePWM2 together using SWFSYNC you need to use ePWM1's SW Sync. ie. configure ePWM1.SYNCOSEL = 00 and then use the ePWM1.SWFSYNC.

    In your case writing to ePWM2's SWFSYNC will simply cause ePWM2's TBPHS to be loaded in to ePWM2's TBCTR, ePWM1's TBCLK will be unchanged. There is a use for this, syncing software events and PWM2's output... But this will NOT sync ePWM1 to ePWM2.

    To answer your questions more directly:

    1. No, you dont need to set SYNCOSEL = 00 if your are just trying to set ePWM2.TBCTR =TBPHS all you need to do is write to ePWM2 SWFSYNC. 
    2. Yes, if ePWM2.PHSEN =1 then ePWM2.SWFSYNC can always force ePWM2.TBCTR = ePWM2.TBPHS.
    3. When single stepping the PWM's clocking always seems a bit weird, it has to do with the way single stepping is executed. To test this you will need to run the device not single step or halt. Try looking at TBCTL.FREE_SOFT and looks at the options for the TBCTR, may that will help.

    Regards,
    Cody