Skip to content

Instantly share code, notes, and snippets.

@johnhowe
Created February 19, 2011 22:57
Show Gist options
  • Save johnhowe/835460 to your computer and use it in GitHub Desktop.
Save johnhowe/835460 to your computer and use it in GitHub Desktop.
Why do red and green LEDs flash simultaneously?
#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