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.