interrupt port 2 in MSP430F1232

hi everyone;

I’m a new comer in MSP430. I’m trying to use interrupt function in port 2 of MSP430f1232 but it didn’t work. My code is below. Can anyone help me, please?

include <msp430x12x2.h>

void delay1s(void)

{

int x = 100000;

while(x != 0) {x–;}

}

void delay1m (void)

{

int y = 60;

while ( y!= 0)

{

y–;

delay1s();

}

}

int main(void)

{

WDTCTL = WDTPW + WDTHOLD ;

P1DIR = 0xFF;

P1SEL = 0x00;

P1IE = 0x01;

P1OUT = 0x00;

P2IE = 0x00;

P2DIR = 0x00;

for (;:wink:

{

P2DIR = 0xFF;

P2OUT =0x00;

P2DIR = 0x00;

_EINT(); // Enable interrupt

if ( P2IN == 0x01)

{

P1OUT = 0xFF;

delay1m();

}

else

{

P1OUT = 0x80;

delay1m();

P1OUT = 0x40;

delay1m();

}

}

}

// Port 2 interrupt service routine

__interrupt void Port_2(void);

__interrupt void Port_2(void)

{

P2IN = 0x01;

}

When MSP runs, it checks pin 2.0, if pin 2.0 is high, then it turns on pin 1.6 and pin 1.7 , if not, turns on pin 1.7 and pin 1.6 sequentially. When program runs, e.g during delay1m ( delay 1 minute ), I set up pin 2.0 high level, program should stop running delay1m immediately , jump back in position where _EINT() is. But some thing is wrong and it didn’t work. Can anyone please help me?

Thanks for advance.

Hello,

I’m not really into C because i use the msp in pure assembler but as far as i understand your code you try to write to P2IN, wich is an only read register.

I did not really find out, what your trying to do !?

Why don’t you put P2 into input mode and react in the isr with setting the pin and waiting one minute?