/* p2.4.c: Toggling a single LED /* This program turns on the red LED and toggles the blue LED 0.5 sec on and 0.5 sec off. */ #include "TM4C123GH6PM.h" void delayMs(int n); int main(void) { /* enable clock to GPIOF at clock gating control register */ SYSCTL->RCGCGPIO |= 0x20; /* enable the GPIO pins for the LED (PF3, 2 1) as output */ GPIOF->DIR = 0x0E; /* enable the GPIO pins for digital function */ GPIOF->DEN = 0x0E; /* turn on red LED only and leave it on */ GPIOF->DATA = 0x02; while(1) { GPIOF->DATA |= 4; /* turn on blue LED */ delayMs(500); GPIOF->DATA &= ~4; /* turn off blue LED */ delayMs(500); } } /* delay n milliseconds (16 MHz CPU clock) */ void delayMs(int n) { int i, j; for(i = 0 ; i < n; i++) for(j = 0; j < 3180; j++) {} /* do nothing for 1 ms */ } /* This function is called by the startup assembly code to perform system specific initialization tasks. */ void SystemInit(void) { /* Grant coprocessor access */ /* This is required since TM4C123G has a floating point coprocessor. */ SCB->CPACR |= 0x00F00000; }