I'm building a super simple RGB LED controller but in the process have stumbled across what appears to be a bug in the analog write code. If I have code as shown below all outputs on port 2 have the same duty cycle, regardless of what duty is set by AnalogWrite.
/*
Simple Test of analogWrite showing problem*/
int rLedPin = P1_6; // select the pin for the LED
int gLedPin = P2_5; // select the pin for the LED
int bLedPin = P2_4; // select the pin for the LED
void setup() {
// declare the ledPin as an OUTPUT:
pinMode(rLedPin, OUTPUT);
pinMode(gLedPin, OUTPUT);
pinMode(bLedPin, OUTPUT);
}
void loop() {
// write three different outputs
analogWrite(rLedPin, 10);
analogWrite(gLedPin, 100);
analogWrite(bLedPin, 200);
delay(1000);
}
I would expect to see three distinct duty cycles but my logic analyzer (and observation of the LEDs) shows this isn't happening.
I'm using a Rev 1.5 MSP-EXP430G2 Launchpad with an M430G2553 installed. My version of Energia is 0101E0012.
If anyone can provide any suggestions as to a work around, or point out the flaw in my understanding of AnalogWrite and the MSP430s I'd really appreciate it.
Thanks,
Mike.