Jump to content
43oh

Trying to alternate blinking of two LEDs


Recommended Posts

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;
}
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...