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.
Hello all,
I am working with the TMS320F28335 and I have some problems configuring the PWM's. The attached image correspond to PWM1A (green) and PWM1B (blue).
I am trying to make them complementary, so I configured the dead band module in such way. It works fine "almost" all the time, as can be seen. But some times, it happens like in the image, where the PWM1B doesn't complement the other, it only rise in a unexpected and unwanted time.
I don´t play with the EPwm1Regs.DBRED or EPwm1Regs.DBFED values, they are fixed from the very beggining. The registers are shadowed, so I don´t think is a change in any of the values or configuration in the middle of a cycle, that should happen only at the beggining of the chopping period.
Any idea?
Thanks in advance.
Ricardo.
Can you post the code you use to update the PWM registers?
Are you saying you're using the dead-band module to modulate the B output to be the complement of the A? Are you not using the action qualifier and the CMPA and CMPB events? This is a much easier way of generating a complementary pair.
Cricho,
I have attached an example how to initalize the 2833x dead band unit. Compare it with your code and see if you can find any differences.
Hope this helps. Regards.
Hi Chris and Frank,
Thanks for your answers.
Below I post the code and defines I use to configure and to use the DB. I have those defines because I have to alternate between the use of this module to have PWM1A and PWM1B alternating with some time between them, and controlling them separately (hence the activate/deactivate defines).
I hope its clear and enough to see if it's correct, I can post more code if neccesary, but I didn't want to mess too much.
Thanks again!
BTW, Frank, is it possible to get more examples as the one you attached? Now I am fighting with each peripheral manual and example to do each thing, but this one is clear and simple
Ricardo.
// ********** Use of the DB ****************
// Phase A
// Activate dead band
#define PH_A_ACT_LEFT_DB (EPwm1Regs.DBCTL.all |= 0x0003)
// Deactivate dead band
#define PH_A_DEACT_LEFT_DB (EPwm1Regs.DBCTL.all &= 0xFFFC)
// ********** Config of the DB ****************
// 0% 0000 0000 0000 1000 - Active high complementary (PWMxB inverted)
#define DEAD_BAND_CONFIG 0x0008
void init_PWMPhaseA()
{
//--------------------------PWM1------------------------------------
// Setup TBCLK
// Set timer period
EPwm1Regs.TBPRD = (Uint16)Duty_par.Tchopping;
// Phase is 0
EPwm1Regs.TBPHS.half.TBPHS = 0x0000;
// Clear counter
EPwm1Regs.TBCTR = 0x0000;
// Set Compare values
// Set compare A value
EPwm1Regs.CMPA.half.CMPA = 0;
// Set compare B value
EPwm1Regs.CMPB = 0;
// Setup counter mode
// Count up
EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP;
// Disable phase loading
EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE;
// Clock ratio to SYSCLKOUT
EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1;
EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1;
// Master for the PWM CLK
EPwm1Regs.TBCTL.bit.SYNCOSEL = TB_CTR_ZERO;
// Setup shadowing
EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
EPwm1Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
// Load on Zero
EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
EPwm1Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;
// Active High PWMs - Setup Deadband
EPwm1Regs.DBRED = TIME_WAIT_RISE_DOBLE_T_SLOW;
EPwm1Regs.DBFED = TIME_WAIT_FALL_DOBLE_T_SLOW;
// Config deadband: POLSEL - Complementary active high
EPwm1Regs.DBCTL.all = DEAD_BAND_CONFIG;
}
Ricardo
your initialization looks fine. However, when you use your macro " PH_A_DEACT_LEFT_DB" , you will switch both S1 and S0 to zero. This will connect ePWMxB-In to ePWMxB-out. Before this macro has been executed, both ePWMxA and ePWMxB have been clocked by ePWMxA -IN. I guess this switch on line ePWMxB is causing your problems.
To temporarily disable the deadband - unit I'd recommend to set DBRED = DBFED = 0 and keep all the switches S0 to S5 as initialized.
Regarding more simple examples: I am currently designing a new F28335 teaching CD-ROM with simple examples for all peripherals like the one I attached to my previous post. The CD-ROM will be published by Texas Instruments University Program in Q1 /2010.
Regards
Hi,
Thanks for your answer Frank.
I have been checking, that this happens when I change the action qualifier (I do this and the DB activation or deactivation all together to achieve the configuration I want in each moment).
I though that this registers was shadowed, but they are not. Is that right? So, if I change the AQCTLA in some moment within the chopping period, this change may be reflected directly in the PWM outputs.
Is this correct? (in case affirmative, then I understand what is going on).
Cheers,
Ricardo