MPC5643L FlexPWM DISMAP question

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

MPC5643L FlexPWM DISMAP question

977 Views
zili
Contributor II

Hi, I just recently got my hands on the demo kit and started reading through the example code. There are two questions for the following section of code. 

// Switch on all FlexPWM channels
SWITCH_ALL_PWM_ON(M1.uni3PeriphCfg.flexPwmBaseAddr);

 

// Enable FlexPWMA/FlexPWMB fault protection
FAULT_PROTECT_PWMA_ON(M1.uni3PeriphCfg.flexPwmBaseAddr);
FAULT_PROTECT_PWMB_ON(M1.uni3PeriphCfg.flexPwmBaseAddr);

 

// Switch off all FlexPWM channels
SWITCH_ALL_PWM_OFF(M1.uni3PeriphCfg.flexPwmBaseAddr);

First, is it required to switch on FlexPWM channels first before configuring DISMAP? It's not mentioned in the MPC5643L reference manual in nowhere. If so, why?

 

Second, the subfunction of FAULT_PROTECT_PWMA_ON actually clears DISA in DISMAP. However, if DISA is zero, the fault protection is disabled as seen in figure 25-27 and following quote.

The PWMA output will be turned off if there is a logic 1 on a FAULTx input and a 1 in the corresponding
bit of the DISA field. 

But the comment of the code indicates it is for enabling fault protection?

 

Many thanks.

Labels (1)
Tags (1)
0 Kudos
3 Replies

678 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

Could you please specify which example do you refer to?

 

I see no reason for switching on FlexPWM channels before configuring DISMAP.

Also as you wrote, if FAULT_PROTECT_PWMA_ON actually clears DISA in DISMAP, then the comment is not correct.

BR, Petr

0 Kudos

678 Views
zili
Contributor II

Please see the following code in the main loop, sections related to DISMAP are highlighted.

void main (void)
{
DISABLE_IRQ();
// Initializing of clock, reset, core mode etc.
sys_init();

// Initializing wait states in for FLASH read/write
//flash_init_fnc();

// Initialize UART
uart_init();

// FreeMASTER initialization
FMSTR_Init();

// Siu initialize
siul_init();

// Initialize DSPI module
dspi_init();

// Initialize PIT timer module
pit_init();

// Initialize SBC power source
mc33905Config(&sbcDrv);

// Initialize FlexPWM module
flexpwm0_init();
flexpwm1_init();

// Initialize CTU module
ctu_init();

// Initialize eTimer0, eTimer1, eTimer2 module
etimer0_init();
etimer1_init();

// Initialize ADC_0 module with HW offset cancellation
adc0_init();
adc_off_canc(&ADC_0);

// Initialize ADC_1 module with HW offset cancellation
adc1_init();
adc_off_canc(&ADC_1);

// MC33937 Configuration with Double RESET Timing logic
// Since the reset pin is common for both power stages, the configuration
// is done automatically for both PWSTGs in one step !!!
mc33937DoubleReset(&(M1.preDrv));

#ifdef UNI3_1
// Initialize MC33937 driver on 3ph Low voltage power-stage
mc33937Config(&(M1.preDrv));
mc33937Enable(&(M1.preDrv));
mc33937ReadSr(&(M1.preDrv));
if (M1.preDrv.status.sr0.R!=0) M1.faultID.B.WrongHardware = 1;

M1.cntrState.state = init;
M1.cntrState.event = e_init;

// Switch on all FlexPWM channels
SWITCH_ALL_PWM_ON(M1.uni3PeriphCfg.flexPwmBaseAddr);

// Enable FlexPWMA/FlexPWMB fault protection
FAULT_PROTECT_PWMA_ON(M1.uni3PeriphCfg.flexPwmBaseAddr);
FAULT_PROTECT_PWMB_ON(M1.uni3PeriphCfg.flexPwmBaseAddr);

// Switch off all FlexPWM channels
SWITCH_ALL_PWM_OFF(M1.uni3PeriphCfg.flexPwmBaseAddr);
#endif

#ifdef UNI3_2
// Initialize MC33937 driver on 3ph Low voltage power-stage
mc33937Config(&(M2.preDrv));
mc33937Enable(&(M2.preDrv));
mc33937ReadSr(&(M2.preDrv));
if (M2.preDrv.status.sr0.R!=0) M2.faultID.B.WrongHardware = 1;

M2.cntrState.state = init;
M2.cntrState.event = e_init;

// Switch on all FlexPWM channels
SWITCH_ALL_PWM_ON(M2.uni3PeriphCfg.flexPwmBaseAddr);

// Enable FlexPWMA/FlexPWMB fault protection
FAULT_PROTECT_PWMA_ON(M2.uni3PeriphCfg.flexPwmBaseAddr);
FAULT_PROTECT_PWMB_ON(M2.uni3PeriphCfg.flexPwmBaseAddr);

// Switch off all FlexPWM channels
SWITCH_ALL_PWM_OFF(M2.uni3PeriphCfg.flexPwmBaseAddr);
#endif

// CTU MRS_O clearing
if(pCTU->CTUEFR.B.MRS_O) pCTU->CTUEFR.B.MRS_O = 1;

// Enable all interrupts
// Ensure INTC's current priority is 0
INTC.CPR_PRC0.B.PRI = 0;
// Enable external interrupts
ENABLE_IRQ();

while(1)
{
// Reading faults from MC33937 pre-driver - the same pin for both Power Stages
if (GET_SIUL_INPUT_VAL(SIUL_PAD_53))
{
#ifdef UNI3_1
if (M1.cntrState.readFault)
{
mc33937ReadSr(&M1.preDrv);
if (M1.preDrv.status.sr0.R!=0) M1.faultID.B.WrongHardware = 1;
M1.cntrState.readFault = false;

}
#endif

#ifdef UNI3_2
if (M2.cntrState.readFault)
{
mc33937ReadSr(&M2.preDrv);
if (M2.preDrv.status.sr0.R!=0) M2.faultID.B.WrongHardware = 1;
M2.cntrState.readFault = false;
}
#endif
}

// FreeMaster polling function, shall be executed on background
FMSTR_Poll();

}
}

0 Kudos

678 Views
zili
Contributor II

Hi Petr,

The example is MTRCKTDPS5643L, which comes with the demo kit of 'AN4518 Dual 3-Phase PMSM Development Kit with MPC5643L'.

Thanks.

0 Kudos