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

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

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

1,807 Views
plabgh
Contributor I

(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...

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

1,317 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

There is no OPWFM mode supported on this MCU. Just OPWFMB mode can be used on some eMIOS channels (big channels).

See Table 209. Channel descriptions of the device Reference manual to know which modes are available on each channels.

From your selected channels just channel 0 supports OPWFMB mode, but you need to set the MODE = 0x58 as per Table 221.

BR, Petr

0 Kudos
Reply

1,316 Views
snehakalkhair
Contributor III

Hi,

Can you please help me with the min and max frequency/frequency range in which eMIOS can work for MPC5674F?

I have a 40 MHz crystal.

0 Kudos
Reply

1,317 Views
plabgh
Contributor I

yes,you are right, MODE=0x58 can oupt pwm wave, but only Channel-0, 8, 9, 10, 12, 14, 15, 23 support OPWFMB mode.

I want to use the channel as much as possible to output pwm wave that its period and duty cycle is variable.

So, I select to set MODE=0x19. (datasheet  21.5.1.1.13 Output Pulse Width and Frequency Modulation (OPWFM) Mode)

What do I need to do to achieve it ?

tks.

what I should to do?

0 Kudos
Reply

1,316 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

As I wrote and Table 209 states there is no OPWFM mode supported, so if you select it the channel will not work.

The chapter 21.5.1.1 describes all possible modes of eMIOS module, but only few of modes are implemented on the MPC5634M’s eMIOS module, as per Table 209 states.

Thus you can only generate variable period and duty cycle PWM on Big channels (0, 8, 9, 10, 12, 14, 15, 23).

The medium channels offers OPWMB mode, but this mode uses external counter bus , so the period is given by that selected external counter bus.

BTW: you can also use the eTPU module for PWM signal generating.

BR, Petr

0 Kudos
Reply