Quantcast
Channel: MSP430 Technical Forums
Viewing all articles
Browse latest Browse all 2077

Trying to alternate blinking of two LEDs

$
0
0

Sometimes when I run this code, the LEDs will blink alternatingly, while other times they will blink synchronously. Why is that?  

  

#include <msp430.h>
 
int main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
P1DIR |= 0x01; // Set P1.0 to output direction
P1DIR |= 0x40;
 
for(;; ) {
volatile unsigned int i; // volatile to prevent optimization
 
P1OUT ^= 0x01; // Toggle P1.0 using exclusive-OR
 
for(i=0;i<10000;i++){} // SW Delay
P1OUT ^= 0x40;
}
 
return 0;
}

Viewing all articles
Browse latest Browse all 2077

Trending Articles