Skip to content

Instantly share code, notes, and snippets.

@ArnaudCourbiere
Last active December 10, 2015 18:48
Show Gist options
  • Save ArnaudCourbiere/4476651 to your computer and use it in GitHub Desktop.
Save ArnaudCourbiere/4476651 to your computer and use it in GitHub Desktop.
#include <msp430.h>
#include <legacymsp430.h>
#define LED0 BIT0
#define LED1 BIT6
#define LED_DIR P1DIR
#define LED_OUT P1OUT
#define BUTTON BIT3
volatile unsigned int blink = 1;
void initLEDs(void) {
LED_DIR |= LED0 + LED1;
// LED_OUT &= ~(LED0 + LED1);
LED_OUT |= (LED0 + LED1);
}
int main(void) {
WDTCTL = WDTPW + WDTHOLD;
initLEDs();
P1IE |= BUTTON; // Set button to trigger interrupt (I think)
WRITE_SR(GIE); //Enable global interrupts
while (1) {
if (blink) {
LED_OUT ^= (LED0 + LED1);
__delay_cycles(100000); // SW delay of 100000 cycles at 1Mhz
}
}
return 0;
}
interrupt(PORT1_VECTOR) PORT1_ISR(void)
{
// LED_OUT ^= (LED0 + LED1);
blink ^= 0x01;
LED_OUT &= ~(LED0 + LED1);
P1IFG &= ~BUTTON; // P1.3 IFG cleared
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment