Part Number: MSP430G2553
Tool/software: Code Composer Studio
Hello everyone,
I'm new to the microcontroller so bare with me please. I'm having a problem with the interrupt function I think. I want the RED LED to blink, and when push button is pressed, switch the blinking to GREEN LED. And switch to other LED for all subsequent button pressed. I have the fallowing code but I cant find away to go back to RED led. It seems that I have the green led stuck in while loop but I wrote that the while loop should be executed when the button is pressed and I cleared the interrupt too after that. but still I cant find a way to switch back to RED LED.
/**
* PRACTICE
*/
void main(void)
{
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
P1DIR |= 0x41; // configure P1.0 as output
P1REN |= 0X08;
P1IE |= 0X08;
__enable_interrupt ();
while(~(P1IN & 0x08))
{
P1OUT ^= 0x40;
P1OUT &= ~0x01;
for(i=10000; i>0; i--);
}
}
#pragma vector = PORT1_VECTOR
__interrupt void Port1(void)
{
volatile unsigned int i;
while(P1IN & 0x08)
{
P1OUT ^= 0x01;
P1IFG &= ~0x08;
P1OUT &= ~0x40;
for(i=10000; i>0; i--);