Home > Blog > MSP430 Serial PWM using one timer and WDT

MSP430 Serial PWM using one timer and WDT

Posted by admin on July 31, 2011

Ok, i got pwm and serial working properly together.
That means i can dim leds, and control motor speeds.

Complete explanation with code, and Youtube video in the full post.

You must install Adobe Flash to view this content.

 

 


 

Basically, PWM (Pulse Width Modulation), means you switch a channel on and off at just the right speed, using a timer or counter, to lower the output signal strength . That way you can dim a led, or as i will do, adjust motor speed.

In this test program i have 2 software pwm channels driven by the Watchdog Timer. The eventual use will be to drive the car backward and forward at adjustable speeds while keeping the main timer for the serial connection if in control mode, or the sensors in standalone mode.

You can send "1" from windows hyperterminal (usually com3 for the launchpad, but check the device manager to be sure) and the active led lights up a bit more. keep pressing 1 to light up to max. Keep "2" pressed and the led fades out. "3" Switches between the leds, and turns pwm mode on again if you activated the blinkymode. That blinkymode is selected by ascii "4" over the launchpad serial.

MSP430 Software Side:

Again, this is written for the MSP430G2252, and completely unoptimized testcode, but no reason it should not work for the G2231 (with minor adjustments?)

I basically started using the WatchDog timer PWM code from the site of jsolarski: http://justinstech.org/2010/10/msp430-interrupt-driven-pwm/

Then i added that to my general serial controlled led blinking program: (Blog post and code here) and started adjusting it.
The code should explain most for those that read this, but otherwise don't hesitate to ask or comment on Markoez.com, any of the forums, or youtube.

Code in text file here, as i still don't know how to properly paste in this page :p

Cheers!

p.s. Pushbutton P1.3 code does not work properly. Don't press it too often...

Comments:

Posted by Mallappa Tarageri on
Dear Sir,

Can you help me for getting this code, I am new to MSP430, Please help me for Genarating PWM Signal with timer Interrupt Using MSP430G2231.
Leave a Reply



(Your email will not be publicly displayed.)

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