/* * Toggle PORTB in C programming language for TI Tiva LaunchPad * with Wytec EduBase. On Wytec EduBase board, PB3-PB0 are connected * to the four LEDs. * Default system clock 16 MHz is used. */ #include "TM4C123GH6PM.h" void delayMs(int n); void delayUs(int n); int main(void) { volatile unsigned char readback; // enable PORTB 3-0 as output SYSCTL->RCGCGPIO |= 0x02; // enable clock to GPIOB readback = SYSCTL->RCGCGPIO; // make sure the clock is enabled GPIOB->DIR |= 0x0F; // set PORTB 3-0 as output pins GPIOB->DEN |= 0x0F; // set PORTB 3-0 as digital pins for (;;) { GPIOB->DATA = 0x05; // turn on PB2, 0 delayMs(500); GPIOB->DATA = 0x0A; // turn on PB3, 1 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; }