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.

Setting ePWM high indefinitely or for a particular period of time

Hi all, 

I have this below code, my aim is to set the epwm output high for a predetermined period of time (for example in one loop) and switch it at 50kHz in another loop.

I am wondering if setting the Action Qualifier registers (AQCTLA and AQCTLB) to set at zero without clearing it , means its ePWMxA and ePWMxB are ON (High).

I set it as below but it seems it is not right. Please can anyone help me on this (How to set ePWMxA/ePWMxB High for a time longer than the TBPRD (i.e not switching but remains HIGH) .

Thanks in advance.

EPwm4Regs.TBPRD = 1999;
EPwm5Regs.TBPRD = 1999;

EPwm4Regs.CMPA.bit.CMPA = EPwm4Regs.TBPRD/2;
EPwm4Regs.CMPB.bit.CMPB = EPwm4Regs.TBPRD/2;


EPwm5Regs.CMPA.bit.CMPA = EPwm5Regs.TBPRD/2;
EPwm5Regs.CMPB.bit.CMPB = EPwm5Regs.TBPRD/2;

//Loop1: Set ePWM4A = ePWM4B = ePWM5A = ePWM5B = 1; as long as Input voltage is positive (50Hz AC Input)

EPwm4Regs.AQCTLA.bit.ZRO = 2; EPwm5Regs.AQCTLA.bit.ZRO = 2;

EPwm4Regs.AQCTLB.bit.ZRO = 2; EPwm5Regs.AQCTLB.bit.ZRO = 2;

// loop2 :  switch at 50khz ( as long as the input voltage is negative (negative halfCycle AC)

EPwm4Regs.CMPA.bit.CMPA = ..............;   // different from above
EPwm4Regs.CMPB.bit.CMPB = ............;   // different from above


EPwm5Regs.CMPA.bit.CMPA = ............................;     // different from loop1
EPwm5Regs.CMPB.bit.CMPB = ......................;         // different from loop 1

EPwm4Regs.DBCTL.bit.OUT_MODE = 3; //DB_FULL_ENABLE
EPwm4Regs.DBCTL.bit.POLSEL = 2; // Active High complemenatry; produces the epwmxb as inverse of epwma
EPwm4Regs.DBCTL.bit.IN_MODE = 0; // ePWMA is the source
EPwm4Regs.DBRED.bit.DBRED = 100; // 1.25 microseconds delay
EPwm4Regs.DBFED.bit.DBFED = 100; // for rising and falling edge

//epwm switching action

EPwm4Regs.AQCTLA.bit.CAU = 2;   // set at CAU
EPwm4Regs.AQCTLA.bit.CBU = 1;           //clear at CBU


EPwm5Regs.AQCTLA.bit.CAU = 2;
EPwm5Regs.AQCTLA.bit.CBU = 1;