Skip to content

Instantly share code, notes, and snippets.

@petergsimon
Forked from gregpayne/button_ISR.c
Created July 16, 2013 13:46
Show Gist options
  • Save petergsimon/6008840 to your computer and use it in GitHub Desktop.
Save petergsimon/6008840 to your computer and use it in GitHub Desktop.
//******************************************************************************
// December 2012
// Built with Code Composer Studio v4
//******************************************************************************
#include <msp430.h>
unsigned int i;
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1DIR |= BIT0; // Set P1.0 to output direction
P1DIR |= BIT6; //Set P1.6 to an output
P1DIR = ~BIT3; // P1.3 must stay at input
P1OUT &= ~BIT0; // set P1.0 to 0 (LED OFF)
P1OUT |= BIT6; //Set P1.6 to 1 (LED ON)
P1IE |= BIT3; // P1.3 interrupt enabled
P1REN |= BIT3; //Set P1.3 internal pull up
P1IFG &= ~BIT3; // P1.3 IFG cleared
//LPMx - Low Power Mode
_BIS_SR(LPM3_bits + GIE); // Enter LPM3 w/interrupt
}
// Port 1 interrupt service routine
#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{
P1OUT ^= BIT0; // P1.0 = toggle
P1OUT ^= BIT6; // P1.6 toggle
//P1IFG &= ~BIT3; // P1.3 IFG cleared
//debounce delay
i = 10000;
do i--;
while(i != 0);
P1IFG &= ~BIT3; // P1.3 IFG cleared
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment