7 years, 3 months ago.

LPC1768. PWM works only with p21.

Here is my code:

#include "mbed.h"

Serial pc(USBTX, USBRX);
PwmOut An_Out(p21);
An_Out.period_ms(2); 
float brightness = 0.0;

int main()
{
    while(1) {

 char c = pc.getc();

 if((c == 'u') && (brightness < 0.99)) {
        brightness += 0.01;
        An_Out = brightness;
if((c == 'd') && (brightness > 0.0)) {
        brightness -= 0.01;
        An_Out = brightness;
}
}

PWM works fine but only for p.21. If I assign it to any other pin (p10, p11, ...p20..) it won't work. LED1-LED4 start blinking: "Lights of Death" and that's it. Am I missing something here?

Please advise!

1 Answer

7 years, 3 months ago.

Check documentation first! PWM pins on LPC1768: p21-p26.

LPC1768 pinout

Mark, thanks a lot! Problem solved! Regards, Jacob.

posted by Jacob Gorodetsky 02 Feb 2017