/* p2_3.c Toggling LED in C using Freescale header file register definitions. * This program toggles green LED for 0.5 second ON and 0.5 second OFF. * The green LED is connected to PTB19. * The LEDs are low active (a '0' turns ON the LED). */ #include "C:\Freescale\CW MCU v10.5\MCU\ProcessorExpert\lib\Kinetis\iofiles\MKL25Z4.H" /* #include "C:\Freescale\KDS_1.0\eclipse\ProcessorExpert\lib\Kinetis\iofiles\MKL25Z4.H" */ int main (void) { void delayMs(int n); SIM_SCGC5 |= 0x400; /* enable clock to Port B */ PORTB_PCR19 = 0x100; /* make PTB19 pin as GPIO */ GPIOB_PDDR |= 0x80000; /* make PTB19 as output pin */ while (1) { GPIOB_PDOR &= ~0x80000; /* turn on green LED */ delayMs(500); GPIOB_PDOR |= 0x80000; /* turn off green LED */ delayMs(500); } } /* Delay n milliseconds * The CPU core clock is set to MCGFLLCLK at 41.94 MHz in SystemInit(). */ void delayMs(int n) { int i; int j; for(i = 0 ; i < n; i++) for (j = 0; j < 7000; j++) {} }