Quantcast
Channel: MSP430 Technical Forums
Viewing all articles
Browse latest Browse all 2077

[SOLVED] PWM Frequency in Energia

$
0
0

Hello!  

 

I am new to embedded programming and the forums.  For my first task I am trying to generate a clean square wave with a configurable frequency and I figured PWM would be a good way to do this.  Below is my code.  This works to an extent, but during the off time there are regular spikes to 3.6V at about 10kHz as seen in my scope plot.  The scope is a cheap Rigol DS1102.

 

How can I eliminate these spikes?  and is my approach the best approach or is there a better one that may not have the extra spikes?

 

thanks in advance for the help!

void setup() {
// declare pin 14 to be an output:
pinMode(GREEN_LED, OUTPUT);
}

void loop() {
// set the frequency:
analogFrequency(800);

//PWM (Pin, Duty Cycle) - Maximum = 100% = 255
analogWrite(GREEN_LED, 127);

}

800_Hz.png

 

 

MSP-EXP430G2 w/ crystal populated to pins XIN/XOUT

MSP430G2553

Energia 11

Windows 8.1 x64


Viewing all articles
Browse latest Browse all 2077

Trending Articles