PWM on MPC5674F not working

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

PWM on MPC5674F not working

跳至解决方案
3,480 次查看
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){}

 

}

标签 (1)
0 项奖励
回复
1 解答
3,141 次查看
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 项奖励
回复
4 回复数
3,142 次查看
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 项奖励
回复
3,141 次查看
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 项奖励
回复
3,141 次查看
vincentbergeron
Contributor I

How do you feed the clock to the EMIOS??

0 项奖励
回复
3,141 次查看
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 项奖励
回复