Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Thread

LPC2129 PWM

LPC2129 PWM

2004-07-11 by lehighuboy

I'm using the Keil uVision IDE tool and the LPC2129. My question is 
about setting up single edge hardware PWMs. Someone previously 
posted the following code:

REG(PWM0_PR)=0x0000;  //no prescaler - one cpu clk is one PWM clk
REG(PWM0_MCR)=0x0002; //Reset timer counter register on match0
REG(PWM0_PCR)=0x7E00; //enable each individual PWM, single edge
REG(PWM0_TCR)=0x000A; //Reset TC counter

REG(PWM0_MR0)=0x0400; //set up the PWM period
REG(PWM0_LER)|=BIT0;  //Latch the value

REG(PWM0_MR1)=0x0050; //set up initial PWM duty cycle
REG(PWM0_LER)|=BIT1;  //latch the value

REG(PWM0_MR2)=0x0100; //set up initial PWM duty cycle
REG(PWM0_LER)|=BIT2;  //latch the value

REG(PWM0_MR3)=0x150;  //set up initial PWM duty cycle
REG(PWM0_LER)|=BIT3;  //latch the value

REG(PWM0_TCR)=0x0009; //set the TC coutner and enable all PWMs

I added "PINSEL0 = 0x0005800A;" to enable UART1 and PWM 1-3, however 
I'm unsure of what else is required to have an output of the initial 
PWM duty cycle. 

Thanks.

Re: LPC2129 PWM

2004-07-11 by lehighuboy

Frequency: > 1 kHz
Resolution: 16 bit
Channels: 3

My code generates three 16 bit values (0-65535) that are directly 
proportional to 0-100% duty cycle. The following is what I have thus 
far:

PINSEL0 = 0x0005800A; //Enable UART1 RxD1/TxD1 & PWM 1, 2, 3

PWMPR = 0x0000; //no prescaler - one cpu clk is one PWM clk
PWMMCR = 0x0002; //Reset timer counter register on match0
PWMPCR = 0x7E00; //enable each individual PWM, single edge
PWMTCR = 0x000A; //Reset TC counter

PWMMR0 = 0x0400; //set up the PWM period

I'm unsure of how to change PWMPR or PWMMR0 to manipulate the 
frequency and period respectively. In addition, does PWMMR1 need to 
be equated to the 16 bit value in hex in order to set the duty cycle?

Thanks.

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.