About MPC5744P PWM Input capture

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

About MPC5744P PWM Input capture

1,142件の閲覧回数
damonmeng
Contributor II
Hi All,
About MPC5744P PWM Input capture,it happened a question:
I select the FlexPWM_0 Auxiliary Input 2,the Pad is 102,the signal is Square,DUTY 75%,Whatever 100Hz/500Hz/1KHz/5KHz,Get CVAL0 & CVAL1 is all Fault.Please see the question.Thanks!
MC_CGM.AC0_SC.R = 0x02000000;    
MC_CGM.AC0_DC0.R = 0x80000000|(4 << 16);    
    SIUL2.MSCR[98].B.SRC = 0b00;
    SIUL2.MSCR[98].B.OBE = 0;
    SIUL2.MSCR[98].B.ODE = 0;
    SIUL2.MSCR[98].B.SMC = 0;
    SIUL2.MSCR[98].B.APC = 0;
    SIUL2.MSCR[98].B.IBE = 1;
    SIUL2.MSCR[98].B.PUS = 1;
    SIUL2.MSCR[98].B.PUE = 1;
    SIUL2.MSCR[98].B.SSS = 0b0001;
    SIUL2.IMCR[96].B.SSS = 0b0010;
    FlexPWM_0.OUTEN.R = 0x110;
    FlexPWM_0.SUB[2].CTRL1.R = 0x0400 | (3 << 4)
    FlexPWM_0.SUB[2].CTRL2.R = 0x2000;
    FlexPWM_0.SUB[2].DTCNT0.R = 0x0000;
    FlexPWM_0.SUB[2].DTCNT1.R = 0x0000;
    FlexPWM_0.SUB[2].INIT.R = 0x0;
    FlexPWM_0.SUB[2].VAL0.R = 4096/2;  // PWMX rising edge
    FlexPWM_0.SUB[2].VAL1.R = 4096;  // PWMX falling edge
    FlexPWM_0.SUB[2].DISMAP.R = 0x0000;
    FlexPWM_0.SUB[2].CAPTCMPX.B.EDGCMPX = 0b1000;

    FlexPWM_0.SUB[2].CAPTCTRLX.B.CFXWM = 0b00;
    FlexPWM_0.SUB[2].CAPTCTRLX.B.EDGCNTX_EN = 0b0;
    FlexPWM_0.SUB[2].CAPTCTRLX.B.INPSELX = 0b0;
    FlexPWM_0.SUB[2].CAPTCTRLX.B.EDGX1 = 0b01;
    FlexPWM_0.SUB[2].CAPTCTRLX.B.EDGX0 = 0b10;
    FlexPWM_0.SUB[2].CAPTCTRLX.B.ONESHOTX = 0b1;
    FlexPWM_0.SUB[2].CAPTCTRLX.B.ARMX = 0b0;
    FlexPWM_0.MCTRL.B.LDOK = 0b0100;
main
    FlexPWM_0.MCTRL.B.RUN = 0b0100;

    for(;;)
    {

    FlexPWM_0.SUB[2].CAPTCTRLX.B.ARMX = 0b1;
    while(!(0x0080 & FlexPWM_0.SUB[2].STS.R)){};  // wait for capture flag X1

    txmsg.data[0] = 0;
    txmsg.data[1] = (FlexPWM_0.SUB[2].CVAL0.R) >> 8;
     txmsg.data[2] = FlexPWM_0.SUB[2].CVAL0.R;
    txmsg.data[3] = 0;

    txmsg.data[4] = 0;
     txmsg.data[5] = (FlexPWM_0.SUB[2].CVAL1.R) >> 8;
    txmsg.data[6] = FlexPWM_0.SUB[2].CVAL1.R;
    txmsg.data[7] = 0;


     FlexPWM_0.SUB[2].STS.R = 0x00C0; // clear CFX1/CFX0 flags
     }
0 件の賞賛
返信
2 返答(返信)

771件の閲覧回数
chosp
Contributor III

I am experiencing a similar issue with capture.

Doesn't matter which prescaler value I use for the PWM counter, the CVAL1 - CVAL0 yields the same counter difference.

0 件の賞賛
返信

769件の閲覧回数
chosp
Contributor III

Solved, forgot to set LDOK after configure.

0 件の賞賛
返信