Part Number: MSP430F5529
Hi All,
newbie here.
I have been playing around with some code along with the MSP430F5529 launch pad. I am currently trying to get my head around interupts. Please could someone explain where i am going wrong with my (simple) code ?
When i use break points, It would seem that the program is hitting the interrupt, but the while loop is not acknowledging the flag ==1 ?
#include "msp430.h"
volatile int flag = 0;
void main(void)
{
P1REN = 0x02; //enables pull up resistor on switch p1.1
P1DIR = 0x01; //set led P1.0 as output and switch p1.1 as input
P1OUT = 0x02; //LED off by defalt, SW pulled high
P1IES |= 0x02; //interupt on sw high->low (1)
P1IFG &= ~0x00; //clear flag
P1IE |= 0x02; //enables interupts on pin 1.1
__enable_interrupt();
while(1)
{
if (flag == 1)
{
P1OUT ^= 0x01; //LED on
flag = 0;
}
else
{
//do nothing
}
}
}
#pragma vector = PORT1_VECTOR
__interrupt void P1_ISR(void)
{
flag = 1;
P1IFG &= ~0x00; //clear flag
}
Thanks in advance,