MPC5744P phase-shifted PWM

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MPC5744P phase-shifted PWM

Jump to solution
1,661 Views
seize
Contributor III

Hi

I am trying to generat phase shifted PWM waveform with FlexPWM module.

Three sub-modules of FlexPWM[0] were used to generate PWM waveform with complementary pair.

But the problem is I have problem with "Phase shift".

Attached picture is 6 PWM waveform with 120' phase difference.

How can I generate PWM waveform as in the picture?

pastedImage_2.png

Labels (1)
0 Kudos
1 Solution
1,251 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

The easiest way will be starting the submodules PWM generator by SW after some delay. However using this you probably do not achieve exact 120° shift.

 

Thus one possible way could be init the CTN register by shifted value when PWM generators are disabled.

The FORCE feature can be used for this. If you set the FRCEN bit and have FORCE_SEL=0 within CTRL2 register, then by writing 1 into FORCE bit, the CNT register is initialized with the INIT register value. You can do it when generator is stopped; clear RUN bit, set FORCE bit, set RUN bit again. Of course you need to update INIT values back to proper value before generator is started.

BR, Petr

View solution in original post

0 Kudos
3 Replies
1,252 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

The easiest way will be starting the submodules PWM generator by SW after some delay. However using this you probably do not achieve exact 120° shift.

 

Thus one possible way could be init the CTN register by shifted value when PWM generators are disabled.

The FORCE feature can be used for this. If you set the FRCEN bit and have FORCE_SEL=0 within CTRL2 register, then by writing 1 into FORCE bit, the CNT register is initialized with the INIT register value. You can do it when generator is stopped; clear RUN bit, set FORCE bit, set RUN bit again. Of course you need to update INIT values back to proper value before generator is started.

BR, Petr

0 Kudos
1,251 Views
seize
Contributor III

Hi Petr,

Thanks for your kind help.

Based on your comments, I set the FlexPWM module as follow. But FlexPWM module didn't work.

Can you please check my code.

Best regards,

Hyuntae Choi

static void FlexPWM_0_Init()

{

FlexPWM_0.MCTRL.B.RUN = 0x0000; // Clear Run Bit

FlexPWM_0.SUB[0].CTRL1.R = 0x0400; // full cycle reload, every opportunity,IPBus/1, double switching enable
FlexPWM_0.SUB[0].CTRL2.R = 0x0000; // PWM A and PWM B form a complementary PWM pair
FlexPWM_0.SUB[0].DTCNT0.R = 0x0005; // 1us deadtime values for PWM A0
FlexPWM_0.SUB[0].DTCNT1.R = 0x0005; // 1us deattime values for PWM B0
FlexPWM_0.SUB[0].VAL1.R = 0x007D; // 40khz PWM module
FlexPWM_0.SUB[0].VAL2.R = 0x0000; // PWM A0 rising edge
FlexPWM_0.SUB[0].VAL3.R = 0x0030; // PWM A0 falling edge = Duty cycle = 48

FlexPWM_0.SUB[1].CTRL1.R = 0x0400; // full cycle reload, every opportunity,IPBus/1, double switching enable
FlexPWM_0.SUB[1].CTRL2.B.INDEP = 0x0; // PWM A and PWM B form a complementary PWM pair
FlexPWM_0.SUB[1].CTRL2.B.FRCEN = 0x1; // Force Enable
FlexPWM_0.SUB[1].CTRL2.B.FORCE_SEL = 0x000; // Local force signal force
FlexPWM_0.SUB[1].CTRL2.B.FORCE = 0x1; //
FlexPWM_0.SUB[1].INIT.R = 0x0029; //Initial value = 41;
FlexPWM_0.SUB[1].DTCNT0.R = 0x0005; // 1us deadtime values for PWM A1
FlexPWM_0.SUB[1].DTCNT1.R = 0x0005; // 1us deattime values for PWM B1
FlexPWM_0.SUB[1].VAL1.R = 0x007D; // 40khz PWM module
FlexPWM_0.SUB[1].VAL2.R = 0x0000; // PWM A1 rising edge
FlexPWM_0.SUB[1].VAL3.R = 0x0030; // PWM A1 falling edge = Duty cycle =48

FlexPWM_0.SUB[2].CTRL1.R = 0x0400; // full cycle reload, every opportunity,IPBus/1, double switching enable
FlexPWM_0.SUB[2].CTRL2.B.INDEP = 0x0; // PWM A and PWM B form a complementary PWM pair
FlexPWM_0.SUB[2].CTRL2.B.FRCEN = 0x1; // Force Enable
FlexPWM_0.SUB[2].CTRL2.B.FORCE_SEL = 0x000; // Local force signal force
FlexPWM_0.SUB[2].CTRL2.B.FORCE = 0x1; //
FlexPWM_0.SUB[2].INIT.R = 0x0053; //Initial value = 83;
FlexPWM_0.SUB[2].DTCNT0.R = 0x0005; // 1us deadtime values for PWM A2
FlexPWM_0.SUB[2].DTCNT1.R = 0x0005; // 1us deattime values for PWM B2
FlexPWM_0.SUB[2].VAL1.R = 0x007D; // 40khz PWM module
FlexPWM_0.SUB[2].VAL2.R = 0x0000; // PWM A1 rising edge
FlexPWM_0.SUB[2].VAL3.R = 0x0030; // PWM A1 falling edge = Duty cycle 48

FlexPWM_0.MCTRL.B.RUN = 0xf; // Set Run Bit
FlexPWM_0.OUTEN.R = 0xff0; // enable A and B outputs on submodule 0

FlexPWM_0.MCTRL.B.LDOK = 0xf; 
FlexPWM_0.SUB[1].INIT.R = 0x0000; //Initial value = 00;
FlexPWM_0.SUB[2].INIT.R = 0x0000; //Initial value = 00;

}

0 Kudos
1,251 Views
PetrS
NXP TechSupport
NXP TechSupport

see possible implementation in https://community.nxp.com/docs/DOC-334224 

BR, Petr

0 Kudos