Forums

PWM generation

Started by santosh pn March 30, 2011
Hi,

Can anyone help me with some sample code generate pwm signal on P1_21 for
LPC-2468 ....
Thanks in advance,
S

Love To Live
Live To Love
PN

An Engineer's Guide to the LPC2100 Series

This code does not use P1_21 but rather P1_23. Just make the necessary changes for channel 3 instead of channel 4.

#define P1_21 (5*2)
#define P1_21_PWM1_3 PINSEL3 |= (2 << P1_21) // 10 = PWM1 chan 3

#define P1_23 (7*2)
#define P1_23_PWM1_4 PINSEL3 |= (2 << P1_23) // 10 = PWM1 chan 4
void InitSpeaker ( void )
{
P1_23_PWM1_4; // P1.23 - [PWM1-4] - speaker sound out
}

void OnSpeaker( void )
{
// ARM based design 12,000,000 / 4 = 3,000,000
// Divide by 4 for PCLK no PWM prescaler

#define STANDARD_BEEP_PR2 750 // 4000 Hz

Alert_Power_On (TRUE);

PWM1_TCR = 0x00000002; // reset-resync PWM1 and Counter

PWM1_PCR = 0x00001000; // enable PWM1-4

PWM1_MR0 = STANDARD_BEEP_PR2;

PWM1_MR4 = 375; // 50 % duty cycle

PWM1_LER = 0x00000011; // enable PWM1-4 and PWM1-0 match latch

PWM1_TCR = 0x00000009; // enable PWM1 and Counter
}

void OffSpeaker( void )
{
PWM1_MR4 = 0; // prevents match, thus low output
PWM1_LER = 0x00000011; // enable PWM1-4 Latch
}

From: l... [mailto:l...] On Behalf Of santosh pn
Sent: Wednesday, March 30, 2011 6:14 AM
To: l...
Subject: [lpc2000] PWM generation
Hi,

Can anyone help me with some sample code generate pwm signal on P1_21 for LPC-2468 ....
Thanks in advance,
S

[http://img144.imageshack.us/img144/6315/rose01juneom6.gif]

Love To Live

Live To Love

PN
Thanks much Mark. This will certainly help me...

S
Hi,
>
> Can anyone help me with some sample code generate pwm signal on P1_21 for
>LPC-2468 ....
>Thanks in advance,
>S
>
>Love To Live
>Live To Love
> PN