PWM in LPC2378

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

PWM in LPC2378

跳至解决方案
946 次查看
vivekpjohn
Contributor II

I have a custom board designed based on LPC2378. I want to use the PWM module with 6 single edged PWM outputs. I am able to generate the PWM waveforms. However, the PWM program is free running now i.e it starts and then runs continuously. I want to have control to start, stop, & restart/reset PWM based on some other triggers like software/hardware interrupt, matching some conditions in the code etc. 
I want to know how to start the PWM when some event occurs.
I want to know how to stop the PWM when some event occurs. (before the MR0 value matches)
i want to know how to restart the PWM counter when some event occurs.

标签 (3)
0 项奖励
1 解答
851 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Vivek,

I suppose that you can output PWM signals, but you want to control to start/stop the PWM signals as you expected.

As you know that the PWM signals are designed to output continuous waveform, it is not flexible to start or stop the PWM signals.

Anyway, there are two methods to start/stop PWM waveform, one is to control the Timer Counter, you can enable it to count tick or stop counting tick. Another is to control PWM pins to change the pin logic, while the Timer Counter works normally and continue to count tick, the PWM signals work normally, but just CAN NOT output to PWM pads.

For the first method, you can write the PWM Timer Control Register to start/stop the Timer counter.

pastedImage_1.png

For the second method, you can clear the PWMENAx bits in PWM Control Registers, I suppose that the PWM pins will be in tri-state(high impedance), in the case, you can use external pull-up/down resistor to set the pin logic. Note I am not sure if the PWM pins are in high impedance state when you clear the PWMENAx bits in PWM Control Register, pls have a test. Or you can configure the PWM pins in GPIO mode to set/clear the pin logic as you expected. Pls refer to section 24.7.6 PWM Control Registers (PWM1PCR - 0xE001 804C).

Hope it can help you

BR

XiangJun rong

在原帖中查看解决方案

2 回复数
852 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Vivek,

I suppose that you can output PWM signals, but you want to control to start/stop the PWM signals as you expected.

As you know that the PWM signals are designed to output continuous waveform, it is not flexible to start or stop the PWM signals.

Anyway, there are two methods to start/stop PWM waveform, one is to control the Timer Counter, you can enable it to count tick or stop counting tick. Another is to control PWM pins to change the pin logic, while the Timer Counter works normally and continue to count tick, the PWM signals work normally, but just CAN NOT output to PWM pads.

For the first method, you can write the PWM Timer Control Register to start/stop the Timer counter.

pastedImage_1.png

For the second method, you can clear the PWMENAx bits in PWM Control Registers, I suppose that the PWM pins will be in tri-state(high impedance), in the case, you can use external pull-up/down resistor to set the pin logic. Note I am not sure if the PWM pins are in high impedance state when you clear the PWMENAx bits in PWM Control Register, pls have a test. Or you can configure the PWM pins in GPIO mode to set/clear the pin logic as you expected. Pls refer to section 24.7.6 PWM Control Registers (PWM1PCR - 0xE001 804C).

Hope it can help you

BR

XiangJun rong

851 次查看
vivekpjohn
Contributor II

Hai,

Thank you for your reply. I tried the first method but the output is not consistent. Sometimes it is not getting enabled after a few cycles of start/stop or enable/disable.

Thank you

Vivek John

0 项奖励