/* * Toggle the four LEDs on the Digilent Orbit BoosterPack. * The LEDs are connected to the MCU as: * LD1 PC6 * LD2 PC7 * LD3 PD6 * LD4 PB5 * Default system clock 16 MHz is used. */ #include "TM4C123GH6PM.h" void delayMs(int n); int main(void) { volatile unsigned char readback; SYSCTL->RCGCGPIO |= 0x0E; // enable clock to GPIOB, GPIOC, GPIOD readback = SYSCTL->RCGCGPIO; // make sure the clock is enabled GPIOC->DIR |= 0xC0; // set PORTC 7, 6 as output pins GPIOC->DEN |= 0xC0; // set PORTC 7, 6 as digital pins GPIOD->DIR |= 0x40; // set PORTD 6 as output pins GPIOD->DEN |= 0x40; // set PORTD 6 as digital pins GPIOB->DIR |= 0x20; // set PORTB 5 as output pins GPIOB->DEN |= 0x20; // set PORTB 5 as digital pins for (;;) { // infinite loop GPIOC->DATA &= ~0x40; // turn off LD1 GPIOB->DATA |= 0x20; // turn on LD4 delayMs(500); GPIOB->DATA &= ~0x20; // turn off LD4 GPIOD->DATA |= 0x40; // turn on LD3 delayMs(500); GPIOD->DATA &= ~0x40; // turn off LD3 GPIOC->DATA |= 0x80; // turn on LD2 delayMs(500); GPIOC->DATA &= ~0x80; // turn off LD2 GPIOC->DATA |= 0x40; // turn on LD1 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; }