AnsweredAssumed Answered

My OPWFM demo can't output PWM waveform for MPC5634???

Question asked by wang heng on Jan 20, 2016
Latest reply on Jul 6, 2016 by Sneha Kalkhair

(MPC5634,  system frequency:64MHz)

 

void Pwm_Ini(uint8 Chn)

{

       SIU.PCR[Chn + 179].B.PA  = 1;     /*Initialize PORT*/

       SIU.PCR[Chn + 179].B.OBE = 1;

       EMIOS.MCR.B.MDIS= 0;                 /*EMIOS module enter normal mode */

       EMIOS.MCR.B.GPRE= 63;             /* eMIOS clk= sysclk/(GPRE+1)= 64MHz/64= 1MHz */

       EMIOS.MCR.B.ETB= 0;                  /*External time base is disabled  */

       EMIOS.MCR.B.GTBE= 1;                 /*Enable global time base */

       EMIOS.MCR.B.GPREN= 1;                /*Enable eMIOS clock */

       EMIOS.CH[Chn].CCR.B.MODE= 0x19;      /*Mode is OPWFM*/

       EMIOS.CH[Chn].CCR.B.BSL= 0x3;        /*All channels: internal counter */

       EMIOS.CH[Chn].CCR.B.UCPREN= 1;       /*Prescaler enabled */

       EMIOS.CH[Chn].CCR.B.FEN= 0;          /*Disable interupt */

       EMIOS.CH[Chn].CCR.B.DMA= 0;          /*FLAG assigned to Interrupt request */

       EMIOS.CH[Chn].CCR.B.UCPRE= 0;        /*Prescaler=0,Divide Ratio=1 */

       EMIOS.CH[Chn].CCR.B.IF= 0;           /*select the min input pulse width that can pass through the filter,0 means bypass */

       EMIOS.CH[Chn].CCR.B.FCK= 0;          /*Select clock source for the programmable input filter,0 means Prescaled clock */

       EMIOS.CH[Chn].CCR.B.EDPOL= 0;        /*Polarity-leading edge sets output/trailing clears */

}

 

void Pwm_Output(uint8 Chn,uint32 Period, uint32 DutyCycle)

{

      EMIOS.CH[Chn].CBDR.R = Period;          /* Set  Period */

      EMIOS.CH[Chn].CADR.R = DutyCycle;    /* Set  DutyCycle */

}

 

int main(void)

{

     Pwm_Ini(0);     /* initialize eMIOS[0] */

     Pwm_Ini(2);     /* initialize eMIOS[2] */

     Pwm_Ini(4);     /* initialize eMIOS[4] */

     Pwm_Output(0, 1000, 200);     /* Frequency=1KHz,  DutyCycle=20% */

     Pwm_Output(2, 500, 200);       /* Frequency=2KHz,  DutyCycle=40% */

     Pwm_Output(4, 2000, 200);     /* Frequency=500Hz,  DutyCycle=10% */

}

 

why my OPWFM demo can't output PWM waveform for MPC5634???

eMIOS[0], eMIOS[2], eMIOS[4] channels have not the output of the PWM waveform.

I want to output PWM waveform that its cycle and duty cycle are variable.

anybody know how to solve the problem??

tks...

Outcomes