Home > Blog > MSP430 Controlling leds through pc serial connection

MSP430 Controlling leds through pc serial connection

Posted by admin on June 9, 2011

In the early MSP430 tests i created a blinking LED example that could be controlled through the pc serial connection. Someone on YouTube asked about the code, so i thought i'd post it. See below, small video and explanation first.

Youtube Video Here

Now to create this, i started by stripping the temperature sense demo of everything not necessary, essentially only keeping the clocks setup and serial connection part.Then i added some state based led blink code from an earlier example i modified a little.

Keep in mind though that this was purely created as a private test, and is not optimal yet. For instance, when you press a button on the pc, it instantly sets the new state in an interrupt, but then goes back and finishes it's current blinking cycle before moving to the one you selected. That is because i used "delay_cycles" for the pauses in the blinking.If you would like that optimized, you could switch to timer or counter based blinking, and just reset that as well when a button is pressed (or, char is recieved on RX to be exact)

Edit: Well, a bug creeped into the code, thanks geoper2 for pointing that out!

If you already used the example, at around line 181 the code should be

if (P1IFG & 0x08)  not:  if (P1IFG == 0x08)

or the program halts when you press the button.With the code correction you will cycle through the blinking programs.

Updated code example: MSP430_serial_ledblink_corrected.txt



Posted by admin on
Well i had a major spam attack, and the genuine messages were unfortunately lost as well in the cleanup :(

But thanks Geoper, and the other guy, sorry, cant remember your nick
Leave a Reply

(Your email will not be publicly displayed.)

Please type the letters and numbers shown in the image.Captcha Code