PWM on MPC5674F not working

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

PWM on MPC5674F not working

Jump to solution
1,286 Views
vincentbergeron
Contributor I

I am trying to output PWM en EMIOS CH4 and nothing is happening.  Here is my code:

 

initEMIOS(){

     EMIOS.MCR.B.GPRE = 63;    // Divide by 64

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

     EMIOS.MCR.B.FRZ = 1;         // Enable freeze mode when debugging

     EMIOS.MCR.B.GPREN = 1;   // Enable EMIOS Prescaler

}

 

initEMIOSCh23(){

     EMIOS.CH[23].CADR.R = 99;               // 100 clocks

     EMIOS.CH[23].CCR.B.MODE = 0x50;  // Modulus buffer counter

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

     EMIOS.CH[23].CCR.B.UCPRE = 0;      // Divide by 1

     EMIOS.CH[23].CCR.B.UCPREN  = 1;  // Enable prescaler

}

 

initEMIOSCh4(){

     EMIOS.CH[4].CADR.R = 500;

     EMIOS.CH[4].CBDR.R = 1000;

     EMIOS.CH[4].CCR.B.BSL = 0;     // Use counter channel A

     EMIOS.CH[4].CCR.B.EDPOL = 1;

     EMIOS.CH[4].CCR.B.MODE = 0x20;  // OPWM

     SIU.PCR[183].R = 0x0600;    // Ouput and primary function

}

 

int main(){

 

initEMIOS();

initEMIOSCh23();

initEMIOSCh4();

 

while(1){}

 

}

Labels (1)
0 Kudos
1 Solution
947 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

the channel 23 is used as time base for your channel 4 in OPWM mode, so channel 4’s CADR/CBDR registers have to be set to value between 1 and EMIOS.CH[23].CADR.R to be able to perform a match.

With your setting matching never happen, thus have no toggle on output.

Regards,

Petr

View solution in original post

0 Kudos
4 Replies
948 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

the channel 23 is used as time base for your channel 4 in OPWM mode, so channel 4’s CADR/CBDR registers have to be set to value between 1 and EMIOS.CH[23].CADR.R to be able to perform a match.

With your setting matching never happen, thus have no toggle on output.

Regards,

Petr

0 Kudos
947 Views
alexvinchev
Contributor V

Did you feed clock to the EMIOS?

Check http://cache.freescale.com/files/microcontrollers/doc/app_note/AN4830.pdf , there is EMIOS example, as far as I remember, it was working on my side, when I've tested...

0 Kudos
947 Views
vincentbergeron
Contributor I

How do you feed the clock to the EMIOS??

0 Kudos
947 Views
vincentbergeron
Contributor I

I am trying to find the software example listed in the AN4830 document on the freescale site, but I cannot find it.. Can you send me the link please

0 Kudos