/* www.MicroDigitalEd.com * p6_4.c: Toggle the blue LED using the SysTick interrupt * This program sets up the SysTick to interrupt at 1 Hz. * The system clock is running at 3 MHz, so * 3,000,000-1 for RELOAD register. * In the interrupt handler, the blue LED is toggled. * * Tested with Keil 5.20 and MSP432 Device Family Pack V2.2.0. */ #include "msp.h" int main(void) { __disable_irq(); /* initialize P2.2 for tri-color LEDs */ P2->SEL1 &= ~4; /* configure P2.2 as simple I/O */ P2->SEL0 &= ~4; P2->DIR |= 4; /* P2.2 set as output */ /* Configure SysTick */ SysTick->LOAD = 3000000-1; /* reload with number of clocks per second */ SysTick->CTRL = 7; /* enable SysTick interrupt, use system clock */ NVIC_SetPriority (SysTick_IRQn, 2); /* set priority to 2 */ __enable_irq(); /* global enable interrupt */ while (1) { } } void SysTick_Handler(void){ P2->OUT ^= 4; /* toggle the blue LED */ }