Last active
December 17, 2015 19:10
-
-
Save sourceperl/5658900 to your computer and use it in GitHub Desktop.
Set MSP430 for low power mode
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
// set XTAL 32768 Hz on the board | |
void main(void) { | |
// Stop Watchdog | |
WDTCTL = WDTPW + WDTHOLD; | |
// MCLK:LFXT1CLK/8 | |
// SMCLK:LFXT1CLK | |
BCSCTL2 = 0xF8; | |
// IO setup | |
P1DIR = 0xFF; | |
P1OUT = 0x00; | |
// Timer A0 setup | |
CCTL0 = CCIE; | |
CCR0 = 0; | |
TACCR0 = 0x3FF; // Period of 1023 + 1 cnts, which is 32Hz | |
TACTL = 0x0211; // Timer_A: SMCLK, UP MODE, TAIE | |
// Sleep | |
_BIS_SR(LPM1_bits + GIE); | |
} | |
#pragma vector=TIMERA0_VECTOR | |
__interrupt void Timer_A (void) { | |
// code for flash the LED | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment