Created
February 19, 2011 22:57
-
-
Save johnhowe/835460 to your computer and use it in GitHub Desktop.
Why do red and green LEDs flash simultaneously?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <msp430x20x2.h> | |
#define TICK_HZ 238626 | |
#define RED_LED BIT0 | |
#define GREEN_LED BIT6 | |
void Delay (long ticks); | |
int main() { | |
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog ticksr | |
P1OUT = 0; | |
P1DIR = ( RED_LED | GREEN_LED ); | |
while (1) { | |
Delay (TICK_HZ); | |
P1OUT ^= RED_LED; | |
Delay (TICK_HZ); | |
P1OUT ^= GREEN_LED; | |
} | |
return 0; | |
} | |
void Delay (long ticks){ | |
while (ticks) | |
ticks--; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment