AnsweredAssumed Answered

MPC5744P FlexPWM duty

Question asked by Hyuntae Choi on Dec 4, 2018
Latest reply on Dec 4, 2018 by Petr Stancik

Hi,

I have problem with FlexPWM generating wrong duty.

 

I am generating PWM signals for 3 phase inverter using FlexPWM.

 - PWM frequency is 10kHz

 - PWM A and PWM B operate independently

 - Put duty value using debugger and it applied to VAL3.R and VAL5.R of certain sub-module and rest module's VAL3 and VAL5 vaules are 0.

 - Ex)

         D = duty*1000 // duty is the value inserted from debugger, range is 0~1

          FlexPWM_1.SUB[0].VAL3.R = D;

          FlexPWM_1.SUB[0].VAL5.R = 0;

          FlexPWM_1.SUB[1].VAL3.R = 0;  

          FlexPWM_1.SUB[1].VAL5.R = 0;

          FlexPWM_1.SUB[2].VAL3.R = 0;

          FlexPWM_1.SUB[2].VAL5.R = D;

 

Below is FlexPWM register setting 

 

static void FlexPWM_1_Init(void) // 10khz PWM for inverter
{
FlexPWM_1.OUTEN.R = 0x770; // enable A and B outputs on submodule 0,1,2

/* Submodule 0 Initialisation */
FlexPWM_1.SUB[0].CTRL1.R = 0x0404; // full cycle reload, every opportunity,IPBus/1, LDMOD=1
FlexPWM_1.SUB[0].CTRL2.R = 0xa080; // debug and force enable
FlexPWM_1.SUB[0].INIT.R = 0;
FlexPWM_1.SUB[0].VAL1.R = 1000; // PWM modulo
FlexPWM_1.SUB[0].VAL2.R = 0; // PWM 0A rising edge
FlexPWM_1.SUB[0].VAL3.R = 250; // PWM 0A falling edge
FlexPWM_1.SUB[0].VAL4.R = 0; // PWM 0B rising edge
FlexPWM_1.SUB[0].VAL5.R = 250; // PWM 0B falling edge
FlexPWM_1.SUB[0].DTCNT0.R = 0; // deadtime values
FlexPWM_1.SUB[0].DTCNT1.R = 0; // deadtime values
FlexPWM_1.SUB[0].DISMAP.R = 0x0000; // disable fault pin condition

/* Submodule 1 Initialisation */
FlexPWM_1.SUB[1].CTRL1.R = 0x0404; // full cycle reload, every opportunity,IPBus/1, LDMOD=1
FlexPWM_1.SUB[1].CTRL2.R = 0xa080; // debug and force enable
FlexPWM_1.SUB[1].INIT.R = 0;
FlexPWM_1.SUB[1].VAL1.R = 1000;//500; // PWM modulo
FlexPWM_1.SUB[1].VAL2.R = 0; // PWM 1A rising edge
FlexPWM_1.SUB[1].VAL3.R = 500; // PWM 1A falling edge
FlexPWM_1.SUB[1].VAL4.R = 0; // PWM 1B rising edge
FlexPWM_1.SUB[1].VAL5.R = 500; // PWM 1B falling edge
FlexPWM_1.SUB[1].DTCNT0.R = 0; // deadtime values
FlexPWM_1.SUB[1].DTCNT1.R = 0; // deadtime values
FlexPWM_1.SUB[1].DISMAP.R = 0x0000; // disable fault pin condition

/* Submodule 2 Initialisation */
FlexPWM_1.SUB[2].CTRL1.R = 0x0404; // full cycle reload, every opportunity,IPBus/1, LDMOD=1
FlexPWM_1.SUB[2].CTRL2.R = 0xa080; // debug and force enable
FlexPWM_1.SUB[2].INIT.R = 0;
FlexPWM_1.SUB[2].VAL1.R = 1000;//500; // PWM modulo
FlexPWM_1.SUB[2].VAL2.R = 0; // PWM 2A rising edge
FlexPWM_1.SUB[2].VAL3.R = 250; // PWM 2A falling edge
FlexPWM_1.SUB[2].VAL4.R = 0; // PWM 2B rising edge
FlexPWM_1.SUB[2].VAL5.R = 250; // PWM 2B falling edge
FlexPWM_1.SUB[2].DTCNT0.R = 0; // deadtime values
FlexPWM_1.SUB[2].DTCNT1.R = 0; // deadtime values
FlexPWM_1.SUB[2].DISMAP.R = 0x0000; // disable fault pin condition

FlexPWM_1.MCTRL.R = 0x0f00; // Submodule 1 PWM generator enabled
FlexPWM_1.MCTRL.B.LDOK = 0xf; /* Load the PRSC bits of CTRL1 and the INIT, and VALx registers into a set of buffers */
}

 

I have increased PWM frequency 10kHz to 20kHz by reducing VAL1.R values of each sub-module.

FlexPWM_1.SUB[1].VAL1.R = 500 (sub module 2 and 3 are same)

 

Then, FlexPWM generates PWM signal with wrong duty.

 

 - 10kHz PWM signal with 10% duty

 

-20kHz PWM signal with 10% duty

 

As shown in 20kHz PWM figure, PWM signal with 100% duty was generated when active sub-module is changed. (not always)

The duty value, VAL.3 and VAL5 values were not changed.

 

The duty value was updated every 100u sec(10kHz) based on PWM sub module 0's reload interrupt.

So I changed duty update period to 50u sec but the same problem exist.

 

How can I remove the PWM signal with wrong duty

Outcomes