9 years, 8 months ago.

PWM not working on k64F

I decided to try out the PWM on my k64F board using one of the example programs on the PwmOut page, but it just blinks the red portion of the RGB led at roughly 5Hz and a 50% duty cycle. I have tried using different ports, they all work fine except when I try to use any of the ports connected to the RGB led. Am I missing something really basic here? Here is the program I'm using:

PwmOut Example Program

#include "mbed.h"
 
PwmOut led(PTB21);
 
int main() {
    // specify period first, then everything else
    led.period(4.0f);  // 4 second period
    led.write(0.50f);  // 50% duty cycle
    while(1);          // led flashing
}

Hmm, now I see that PWM is not supported on these pins; I wonder why?

posted by Caleb Washburn 07 Mar 2015

1 Answer

9 years, 8 months ago.

I think your question has been answered in this one http://developer.mbed.org/questions/3774/Are-RGB-led-pins-capable-of-PWM-or-Analo/ and the pins driving the RGB LED are not PWM compatible.