How to set PWM output method using MPC5603P etimer?

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

How to set PWM output method using MPC5603P etimer?

1,619 次查看
mkk_lee
Contributor I

I used a translator.

I used this example.
https://community.nxp.com/t5/MPC5xxx-Knowledge-Base/Example-MPC5604P-PinToggleStationery-CW210/ta-p/...

ETimer_Init(); I added a function, but no PWM output, 5V HIGH output

Is there any way to solve it?

I attach the code.

mkk_lee

0 项奖励
回复
3 回复数

1,613 次查看
petervlna
NXP TechSupport
NXP TechSupport

Hello,

I had a brief look at you code and I see no assignment of PIT channel0 to any output pin in SIU module.

Only GPIO LED toggle in interrupt which is commented out.

Please configure the device according to your needs.

Best regards,

Peter

1,605 次查看
mkk_lee
Contributor I

Do you have any examples to refer to?

0 项奖励
回复

1,602 次查看
petervlna
NXP TechSupport
NXP TechSupport

Hello,

Its hard to say, here is the general code (bare metal), but it always depends on the HW you are using.

 

void SIUL_init(void)
{
SIU.PCR[4].R = 0x0400; // pin for output eTimer1_CH[0] enable A[4]
}//SIUL_init

void eTimer_init(void)
{
//Initialize eTimer1_ch0 to generate pwm output signal
ETIMER_1.CHANNEL[0].CNTR.R = 0x0000; // Initial value
ETIMER_1.CHANNEL[0].CTRL.B.CNTMODE = 0x1; // Counter mode = count rising edges
ETIMER_1.CHANNEL[0].CTRL.B.PRIsrc=0x18; // Primary count source = IBBus clock devide by prescaler 1
ETIMER_1.CHANNEL[0].CTRL2.B.OEN = 0x1; // Output enable
ETIMER_1.CHANNEL[0].CTRL.B.LENGTH = 0x1; // Reload conter after reaching count value
ETIMER_1.CHANNEL[0].LOAD.R = 0x1; // Reload value used to initialize the counter
ETIMER_1.CHANNEL[0].COMP1.R = 0x00; // Compare value for counter
ETIMER_1.CHANNEL[0].COMP2.R = 0x0; // Compare value for counter
ETIMER_1.CHANNEL[0].CTRL2.B.OUTMODE = 0x3; // Toggle OFLAG output on successful compare (COMP1 or COMP2)

ETIMER_1.CHANNEL[0].CMPLD1.R = 0x0;
ETIMER_1.CHANNEL[0].CMPLD2.R = 0x0;
ETIMER_1.CHANNEL[0].CCCTRL.R = 0x8800;

//Enable intrrupt on compare 1 match
ETIMER_1.CHANNEL[0].INTDMA.B.TCF1IE = 0x1; // Timer compare 1 flag interrupt enable

}//eTimer_init