openMSP430: IO functionality test with interupt
#include "omsp_system.h"volatile char shift = 0x01; // Global variableint main(void)
{ WDTCTL = WDTPW | WDTHOLD; // Disable watchdog timer P2DIR = 0xff; // Port 2.0-2.7 = output
P2OUT = shift; // Initialize Port 2 P1DIR = 0x00; // Port 1.0-1.7 = input
P1IE = 0x01; // Port 1.0 interrupt enabled
P1IES = 0x00; // Port 1.0 interrupt edge selection (0=pos 1=neg)
P1IFG = 0x00; // Clear all Port 1 interrupt flags (just in case) eint(); // Enable interrupts while ()
{
if (P2OUT == 0x00)
{
P2OUT = shift;
}
else if (shift == 0x01)
{
P2OUT = (P2OUT << );
}
else
{
P2OUT = (P2OUT >> );
}
}
} // Port1 Interrupt Service Routine
interrupt(PORT1_VECTOR) port1_isr(void)
{
if (P1IFG & 0x01)
{
shift ^= 0x81;
P1IFG &= ~0x01; // Clear Port 1.0 interrupt flag
}
}