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.

28335如何实现负移相?

大家好,我现在在用28335输出带移相角的PMW波形,想实现PWM2既可以超前PWM1,又可以滞后PWM1,但现在只能实现PWM2之后PWM1一定的角度,而且只能实现最大180度的移向,想请教下各位,怎么配置可以实现输出PWM2既可以超前PWM1,又可以滞后PWM1一定角度。

附PWM1 和PWM2配置如下

void InitEPwm1Example()
{
EALLOW;
EPwm1Regs.TBPRD = 3000; // Set timer period PRD=SYSCLKOUT/f/2
EPwm1Regs.TBPHS.half.TBPHS = 0; // Phase is 0
EPwm1Regs.TBCTR = 0x0000; // Clear counter


EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Count up
EPwm1Regs.TBCTL.bit.PHSEN = TB_ENABLE; // 1.Disable->Enable
EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; // Clock ratio to SYSCLKOUT
EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1;
EPwm1Regs.TBCTL.bit.SYNCOSEL= TB_CTR_ZERO; //2.Add

// Setup compare
EPwm1Regs.CMPA.half.CMPA = 3000;
EPwm1Regs.CMPB = 3000;


// Set actions

EPwm1Regs.AQCTLA.bit.CAU = AQ_SET; // Set PWM1A on Zero
EPwm1Regs.AQCTLA.bit.CAD = AQ_CLEAR;


EPwm1Regs.AQCTLB.bit.CAU = AQ_SET; // Set PWM1B on Zero
EPwm1Regs.AQCTLB.bit.CAD = AQ_CLEAR;

// Active Low PWMs - Setup Deadband
EPwm1Regs.DBCTL.bit.OUT_MODE =0x3;
EPwm1Regs.DBCTL.bit.POLSEL = 0x2 ;
EPwm1Regs.DBCTL.bit.IN_MODE = 0x2;
EPwm1Regs.DBRED = 300; //2us deadtime
EPwm1Regs.DBFED = 300;


// Interrupt where we will change the Deadband
EPwm1Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO; // Select INT on Zero event
EPwm1Regs.ETSEL.bit.INTEN = 1; // Enable INT
EPwm1Regs.ETPS.bit.INTPRD = ET_3RD; // Generate INT on 3rd event

EDIS;

}

void InitEPwm2Example()
{
EALLOW;
EPwm2Regs.TBPRD = 3000; // Set timer period
EPwm2Regs.TBPHS.half.TBPHS = 300; // 1.Phase is 90 degree 1500对应90度 最大180度 2us值为300 4.5us值为675
EPwm2Regs.TBCTR = 0x0000; // Clear counter

// Setup TBCLK
EPwm2Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Count up
EPwm2Regs.TBCTL.bit.PHSEN = TB_ENABLE; // 2.Disable ->ENABLE
EPwm2Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; // Clock ratio to SYSCLKOUT
EPwm2Regs.TBCTL.bit.CLKDIV = TB_DIV1; // Slow just to observe on the scope
EPwm2Regs.TBCTL.bit.SYNCOSEL=TB_SYNC_IN; //3.Add

// Setup compare
EPwm2Regs.CMPA.half.CMPA = 3000;
EPwm2Regs.CMPB = 3000;

// Set actions
EPwm2Regs.AQCTLA.bit.CAU = AQ_SET; // Set PWM1A on Zero
EPwm2Regs.AQCTLA.bit.CAD = AQ_CLEAR;


EPwm2Regs.AQCTLB.bit.CAU = AQ_SET; // Set PWM1B on Zero
EPwm2Regs.AQCTLB.bit.CAD = AQ_CLEAR;

// Active Low complementary PWMs - setup the deadband
EPwm2Regs.DBCTL.bit.OUT_MODE = 0x3;
EPwm2Regs.DBCTL.bit.POLSEL = 0x2;
EPwm2Regs.DBCTL.bit.IN_MODE = 0x2;
EPwm2Regs.DBRED =300; //2us deadtime
EPwm2Regs.DBFED =300;


// Interrupt where we will modify the deadband
EPwm2Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO; // Select INT on Zero event
EPwm2Regs.ETSEL.bit.INTEN = 1; // Enable INT
EPwm2Regs.ETPS.bit.INTPRD = ET_3RD; // Generate INT on 3rd event

EDIS;
}