TRK-MPC5604P PWM

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

TRK-MPC5604P PWM

Jump to solution
1,557 Views
simbasoft
Contributor II

I want to create a simple PWM generator to run on the TRK-MPC5604P evaluation board.   I used the code listed in the function initAndRunPwm() below. The counter starts but there is not any output on any of the pins (D9, D10, D11). I suspect it is caused by he fault input, D8. It is supposed to be the Fault[0] input pin. but I'm not sure how to configure it.

 

Any hints what is the issue?

===================================

void initAndRunPwm(void){

    vuint8_t  ldok_test;

 

//  SIU.PCR[56].R = ??;         // D8, Fault[0]

    SIU.PCR[57].R = 0x0600; // D9, X[0]

    SIU.PCR[58].R = 0x0600; // D10, A[0]

    SIU.PCR[59].R = 0x0600; // D11, B[0]

 

    FLEXPWM_0.OUTEN.R    = 0x0111;

    FLEXPWM_0.MASK.R     = 0x0111;

    FLEXPWM_0.SWCOUT.R   = 0x0000;

    FLEXPWM_0.DTSRCSEL.R = 0x0000;   

    FLEXPWM_0.MCTRL.R    = 0x0000;

    FLEXPWM_0.FCTRL.R    = 0x0000;   

    FLEXPWM_0.FSTS.R     = 0x0000;    

    FLEXPWM_0.FFILT.R    = 0x0000;

 

    FLEXPWM_0.SUB[0].INIT.R  = 0xFC00;   

    FLEXPWM_0.SUB[0].CTRL2.R = 0x0010;   

    FLEXPWM_0.SUB[0].CTRL.R  = 0x1400;

 

    FLEXPWM_0.SUB[0].VAL[0].R = 0x0000;

    FLEXPWM_0.SUB[0].VAL[1].R = 0x0400;

    FLEXPWM_0.SUB[0].VAL[2].R = 0xFE00;

    FLEXPWM_0.SUB[0].VAL[3].R = 0x0200;

    FLEXPWM_0.SUB[0].VAL[4].R = 0xFE00;

    FLEXPWM_0.SUB[0].VAL[5].R = 0x0200;   

 

    FLEXPWM_0.SUB[0].OCTRL.R  = 0x0000;   

    FLEXPWM_0.SUB[0].STS.R    = 0x0000;   

    FLEXPWM_0.SUB[0].INTEN.R  = 0x0000;                                           

    FLEXPWM_0.SUB[0].DMAEN.R  = 0x0000;  

    FLEXPWM_0.SUB[0].TCTRL.R  = 0x0000;

    FLEXPWM_0.SUB[0].DISMAP.R = 0x0FFF;

    FLEXPWM_0.SUB[0].DTCNT0.R = 0x0000;

    FLEXPWM_0.SUB[0].DTCNT1.R = 0x0000;

   

    FLEXPWM_0.SUB[0].CAPTCOMPA.R = 0x0000;

    FLEXPWM_0.SUB[0].CAPTCOMPB.R = 0x0000;

    FLEXPWM_0.SUB[0].CAPTCOMPX.R = 0x0000;

   

    FLEXPWM_0.SUB[0].CAPTCTRLA.R = 0x0000; 

    FLEXPWM_0.SUB[0].CAPTCOMPA.R = 0x0000; 

 

    FLEXPWM_0.SUB[0].CAPTCTRLB.R = 0x0000;

    FLEXPWM_0.SUB[0].CAPTCOMPB.R = 0x0000;

   

    FLEXPWM_0.SUB[0].CAPTCTRLX.R = 0x0000; 

    FLEXPWM_0.SUB[0].CAPTCOMPX.R = 0x0000;

  

    ldok_test = FLEXPWM_0.MCTRL.B.LDOK;    // Read the LDOK bit field first
    FLEXPWM_0.MCTRL.B.LDOK  |= 0x0001;
    FLEXPWM_0.MCTRL.R |= 0x0100;   

 

 

}

Labels (1)
Tags (3)
0 Kudos
1 Solution
1,033 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

Yes, the Fault protection will be the reason.

As you configured DISMAP.R = 0x0FFF, you enabled protection from all FAULTx pins.

Even if the external pin is not configured the internal logic may protect the generation if enabled in DISMAP.

So either you can disable the fault logic at all, use DISMAP.R = 0x0000, or properly configure port PCR, PSMI registers, FCTRL and DISMAP register too.

BTW: the FAULT3 is available on the D8 pin, not the FAULT0

If just FAULT3 on D8 pin should be used to disable A[0],B[0] and X[0] outputs, then configure:

FLEXPWM_0.SUB[0].DISMAP.R = 0x0888;

SIU.PCR[56].R = 0x0103;             // D[8] pin as FlexPWM FAULT3 input, pull up enabled

SIU.PSMI[19].R = 1;           // route D[8] into FlexPWM FAULT3 input

FLEXPWM_0.FCTRL.R = 0x0800; // enable automatic fault clearing of FAULT3, a logic 0 on the fault input indicates a fault condition.

The simple FlexPWM init example with fault protection disabled in on https://community.freescale.com/docs/DOC-99927.

Regards,

Petr

View solution in original post

0 Kudos
2 Replies
1,034 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

Yes, the Fault protection will be the reason.

As you configured DISMAP.R = 0x0FFF, you enabled protection from all FAULTx pins.

Even if the external pin is not configured the internal logic may protect the generation if enabled in DISMAP.

So either you can disable the fault logic at all, use DISMAP.R = 0x0000, or properly configure port PCR, PSMI registers, FCTRL and DISMAP register too.

BTW: the FAULT3 is available on the D8 pin, not the FAULT0

If just FAULT3 on D8 pin should be used to disable A[0],B[0] and X[0] outputs, then configure:

FLEXPWM_0.SUB[0].DISMAP.R = 0x0888;

SIU.PCR[56].R = 0x0103;             // D[8] pin as FlexPWM FAULT3 input, pull up enabled

SIU.PSMI[19].R = 1;           // route D[8] into FlexPWM FAULT3 input

FLEXPWM_0.FCTRL.R = 0x0800; // enable automatic fault clearing of FAULT3, a logic 0 on the fault input indicates a fault condition.

The simple FlexPWM init example with fault protection disabled in on https://community.freescale.com/docs/DOC-99927.

Regards,

Petr

0 Kudos
1,033 Views
simbasoft
Contributor II

Thank You, PetrS. That was great help.

0 Kudos