/* * www.microDigitalEd.com * * p2_3.c Toggling all three LEDs of the tri-color LEDs. * When all three LEDs are on, it appears to be white. * The red LED is connected to P2.0. * The green LED is connected to P2.1. * The blue LED is connected to P2.2. * The LEDs are high active (a '1' turns ON the LED). * * Tested with Keil 5.20 and MSP432 Device Family Pack V2.2.0. */ #include "msp.h" void delayMs(int n); int main(void) { P2->SEL1 &= ~7; /* configure P2.2-P2.0 as simple I/O */ P2->SEL0 &= ~7; P2->DIR |= 7; /* P2.2-2.0 set as output */ P2->OUT |= 7; /* turn all three LEDs on */ while (1) { P2->OUT ^= 7; /* toggle P2.2-P2.0 all three LEDs */ delayMs(500); } } /* delay milliseconds when system clock is at 3 MHz */ void delayMs(int n) { int i, j; for (j = 0; j < n; j++) for (i = 250; i > 0; i--); /* Delay */ }