Using the msp430g2553 TI Launchpad to control an RGB led.

It seems like a simple task, but it actually is not. To do RGB control you need three PWM signals from a MSP430. This equates to needing at least one timer that has three capture control registers. The value line parts included with the launchpad have a timer A0 with 3 CCRs. For whatever reason CCR0 is not available as a configurable hardware output; or at least I could not figure out how to use it as such.

Non value line parts (read- non dip msp430s) offer Timer B, which can have as many as 7 CCRs. Finding these parts are difficult as TI does not provide a search function based on number of CCR registers per timer. These would work great. Alternatively you can pick up a value line msp that has two timer As, and is thus capable of 4 hardware PWM signals. This just means a few extra lines of initialization code and keeping track of what color is on what timer. The timers count’s will not be synchronized but this is irrelevant.

I used the MSP430g2553, free from TI via samples here: g2553

There are a few things to configure to your liking. The period and the maximum duty cycle (to prevent burning out LEDs). The period ultumatly sets the PWM frequency. The two Timer As are running off of the DCO at 16Mhz. They will continuosly count up to the period -1 and reset to zero. This alone will do nothing. Each color has a CCR to tell the hardware when to do something. This something is configured in a separate control register, which tells it what to do. In this case it is OUTMOD_7, which changes the pins state at every time the timer = the CCR value. Setting the period to 320 sets the timer frequency to 50Khz, and thus the PWM frequency to the same. Setting a CCR register to 120 would then give you a 50% duty cycle on the corresponding pin. See below for the sample code. The whole code composer project is zipped in there….have fun.

msp430_RGB

5 Comments

Filed under stuff I've made, Uncategorized

5 Responses to Using the msp430g2553 TI Launchpad to control an RGB led.

  1. A wiring diagram would be great to duplicate this project.

    Thanks

  2. schematic

    schematic please

  3. edelmanb

    No schematic here but the pins are commented in main.c

    //timer pin config
    P2SEL |= PIN_GREENLED + PIN_BLUELED; //TA 1.2 on P2.4 TA1.1 on P2.2
    P1SEL |= PIN_REDLED; //TA 0.1 on p1.6

  4. Thanks for this code. I’ve just been getting started with the TI MSP430 launchpad. Who can resist for only $4.30 right? Anyway. I believe I’m failing in the “test for calibration…” check. No matter what I do, when I run the code, the RED led lights up. Since I’m new to this stuff, I was wondering if you could help me understand what that’s checking and how to fix it. Thanks!

    • edelmanb

      If you are failing the calibration check you can continue but the calculations for frequency will not be correct. This and all MSP430s come calibrated from the factory but can be overwritten (accidentally). Simply comment out the code if you desire.

Leave a Reply

Your email address will not be published. Required fields are marked *