I started using MSP430 Launchpad and as I was examining the code for blinking a led I found something odd. The code is this and is a ready example:
http://www.kynix.com/uploadfiles/pdf2286/MSP430F1481IRTDT.pdf
#include <msp430g2553.h>
unsigned int i = 0;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
P1DIR |= 0x01;
for (;;)
{
P1OUT ^= 0x01;
for(i=0; i< 20000; i++);
}
}
In the beginning you have to initialize P1DIR so to set the pin in which the led is connected to output. I searched a lot and everywhere is says that the specific register is just to set the direction. So then I deleted a part of the code and the remaining was this one:
#include <msp430g2553.h>
unsigned int i = 0;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
P1DIR |= 0x01;
for (;;)
{
}
}
Here is the odd part. The led is on!Shouldn't be off? The line of code with P1OUT isn't going to say to MSP if the led is on or off? With only P1DIR nothing should happening. What am I doing wrong?
Added 8 years, 7 months ago.