/* p6_6.c: Toggle the red LED using the SysTick interrupt * This program sets up the SysTick to interrupt at 1 Hz. * The system clock is running at 41.94 MHz. * In the interrupt handler, the red LED is toggled. */ #include int main (void) { __disable_irq(); /* global disable IRQs */ SIM->SCGC5 |= 0x400; /* enable clock to Port B */ PORTB->PCR[18] = 0x100; /* make PTB18 pin as GPIO */ PTB->PDDR |= 0x40000; /* make PTB18 as output pin */ SysTick->LOAD = 41940000/16-1; /* reload with number of clocks per second */ SysTick->CTRL = 3; /* enable SysTick interrupt, use system clock/16 */ __enable_irq(); /* global enable interrupt */ while (1) { /*wait here for interrupt */ } } void SysTick_Handler(void) { PTB->PTOR = 0x40000; /* toggle red LED */ }