Created
July 27, 2010 14:34
-
-
Save adamburmister/492301 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <msp430x20x3.h> | |
void main(void) | |
{ | |
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer | |
P1DIR |= BIT6; // Set P1.6 to output direction | |
P1SEL |= BIT6; // P1.6 to TA0.1 | |
CCR0 = 1000-1; // PWM Period | |
CCTL1 = OUTMOD_7; // CCR1 reset/set | |
CCR1 = 0; // CCR1 PWM duty cycle | |
TACTL = TASSEL_2 + MC_1; // SMCLK, up mode | |
P1IE |= BIT3; // P1.3 interrupt enabled | |
P1IES |= BIT3; // P1.3 Hi/lo edge | |
P1IFG &= ~BIT3; // P1.3 IFG cleared | |
_BIS_SR(LPM0_bits + LPM4_bits + GIE); // Enter LPM4 w/interrupt | |
} | |
// Port 1 interrupt service routine | |
#pragma vector=PORT1_VECTOR | |
__interrupt void Port_1(void) | |
{ | |
P1IFG &= ~BIT3; // P1.3 IFG cleared | |
CCR1 = (CCR1 + 250) % 1000; // Add 25% to PWM | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks Adam. This has really helped me!