MSP430 Polling Vs Interrupt

In this example other than the usual polling method we uses an interrupt to get the switch reading…
In MSP430 port1 interrupt service routine is written like this

#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{

}

I used code composer studio to get the output of interrupt code…The mspgcc interrupt service routine is like this but i failed to get the output using mspgcc

//port1 interrupt service routine
void Port_1 (void) __attribute__((interrupt(PORT1_VECTOR)));
void Port_1 (void)
{

}

This example also reads switch and toggles light…This is the full code of the interrupt program..

/*interrupt.c
ganeshredcobra@gmail.com
GPL
*/
#include <msp430g2553.h>
#define LED1 BIT0
#define LED2 BIT6
#define BUTTON BIT3
volatile unsigned int i;//to prevent optimization
void main(void)
{
WDTCTL=WDTPW+WDTHOLD;
P1DIR |= (LED1+LED2);//
P1OUT &= ~(LED1+LED2);
P1IE |= BUTTON;
P1IFG &= ~BUTTON;

//__enable_interrupt();//enable all interrupts
_BIS_SR(LPM4_bits+GIE);
for(;;)
{}
}

//port1 interrupt service routine
#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{
P1OUT ^= (LED1+LED2);
P1IFG &= ~BUTTON;
P1IES ^= BUTTON;
}
Advertisements