Hi all,
I just received my ez430 and the extra modules (with MSP430F2012) and I am just trying to get my head round some basic stuff, like reading in a port value to detect pushbuttons etc. I must say I am not very experienced so please be gentle :)
I've connected two pushbuttons, one to P1.3 and one to P1.4 and they are pulled up to Vcc with 10K resistors. I've hooked them up to my multimeter and they drop to 0V when the button is pressed so they seem to be working.
I've also coded this little bit of software, using mspgcc and I can't seem to get it to work. I know the LEDs are working as I've done a little blinking lights sequence with them but the following bit of code doesn't seem to 'register' when I press the push buttons.
#include #include
#ifndef __MSP430_2012__ #define __MSP430_2012__ #endif
int main(void){ WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer P1DIR = 0x1D; P1OUT = 0x00;
for (;;){ if ( !(P1IN & 0x10) ){ // button a on port1.3 pressed? P1OUT |= 0x80; // turn on led 1 (port 1.0) } else if ( !(P1IN & 0x08) ){ // button b on port1.4 pressed? P1OUT |= 0x20; // turn on led 2 (port 1.2) } else { P1OUT = 0xFF; } }
}I would appreciate any pointers as it just doesn't seem to work :(
Thanks! Hamza.