Created
October 10, 2017 15:48
-
-
Save joennlae/e59f90b26d9c5dd7c660d13565e0a3c2 to your computer and use it in GitHub Desktop.
MSP430 LED Blink
This file contains hidden or 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 <msp430.h> | |
/** | |
* main.c | |
*/ | |
int main(void) | |
{ | |
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer | |
// Disable the GPIO power-on default high-impedance mode to activate | |
// previously configured port settings | |
PM5CTL0 &= ~LOCKLPM5; | |
// Configure GPIO | |
P1DIR = 0; // Sets all to input that button S2 | |
P1DIR |= BIT0; // Set P1.0 to output direction LED2 | |
P4DIR |= BIT6; // Set P4.6 to output direction LED1 | |
P1REN |= BIT1; // activate pullup resistors for buttons S2 | |
P1OUT |= BIT1; | |
for(;;){ | |
volatile unsigned int i; | |
if(!(P1IN & 0x02)){ | |
P1OUT ^=0x01; // Toggle LED 1 | |
P4OUT &=~BIT6;//0xBF; | |
} | |
else{ | |
P4OUT ^=0x40; // Toggle LED 2 | |
P1OUT &=~BIT1;//0xFE; | |
} | |
i=10000; | |
do{ | |
--i; | |
} | |
while(i != 0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment