EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Starting with PWM lpc2148

Started by "ernst.cozijnsen" January 19, 2009
Hi All,

I'm trying to start with PWM to fade my leds but to be honnest i feel
like reading swahili if i go through the manual from the 2148 ;-)

I also looked at the code of jcwren butt ehh nope i cannot get any
further on this part.
The most difficult i find is that i dont really understand how the
registers work and i cannot find a good explination abot this.

Could somebody provide me with a clear simple sample that points me in
the right direction?

Hope y'all can help this noob out

Gr,

Ernst

An Engineer's Guide to the LPC2100 Series

BTW i'm using a Olimex LPC-P2148 board with Crossworks 1.7 and a ARM-USB-OCD JTAG programmer
You'll learn alot more by doing this yourself trudging through the
manual but here is some code I wirte the first time I did it. I
commented heavily so that I would never need to pick up the manual
again when working on PWM.

I've copied the code directly from my programs done in Keil with no
clean up so there will be some references that aren't related.
You must go through the register definition file manually to make
sure the register names match the manual. I had to use some variants
as the Kiel definition file didn't match the manual exactly.

3 steps to make it work - using PWMs 2 and 5 in this case.

#1: Define the pins as PWM outputs:



#2: Inititialize the PWM registers:



#3 Write to the PWM buffers and then latch into PWM registers each
time you want to update the PWM output.



In the code here, the value written should be between 0 and 600.

The 2024 Embedded Online Conference