SparkFun Forums 

Where electronics enthusiasts find answers.

Discussions on how to get your MSP JTAG programmer up and running.
By mynameispranay
#70700
Hi guys,
I am using the OLIMEX MSP430-169LCD board based on MSP430F169 Uc.

I had just started the programming part and wanted to control the LED on Port 2(pin1) OR P2.1.

I wrote a simple program which is not working :

#include <io430x16x.h>

int main( void )
{

WDTCTL = WDTPW + WDTHOLD;

P2OUT &= ~BIT1; // low
P2DIR |= BIT1; // output

return 0;

}




The code is going under the debugging mode but the LED is not lighting.
My Hardware is working fine as the Demo LCD code which lights UP the LEd, when loaded is working fine.


can you please advise where I am going wrong?

Regards,

pranay
By gm
#70703
That should work but perhaps the problem is that your main() function is returning which it should not in an embedded system. Try this code:
Code: Select all
#include <msp430.h>

void main (void)
{
  WDTCTL = WDTPW | WDTHOLD;

  P2OUT &= ~BIT1;  // LED enabled low
  P2DIR |= BIT1;  // make P2.1 an output

  for (;;) {}  // wait here forever
}
Hope this helps,

gm