Akash Kollipara
Published © GPL3+

Project 1 - LED Blink (Without Libraries)

TM4C123GXL Interfacing LED.

BeginnerShowcase (no instructions)2,491
Project 1 - LED Blink (Without Libraries)

Things used in this project

Story

Read more

Code

Source Code: TIVA - L1 - LED BLINK

C/C++
/*
* main.c
*
* Author: Akash Kollipara
* Date: 16-Dec-2017
*
* Note: White(R+G+B) LED Blink on TM4C123GXL Eval Board
*/
//---SYSTEM CONTROL REGISTERS---//
#define SYS_CTRL_RCGC2  (*((volatile unsigned long *)0x400FE108))   //offset of RCGC2 register is 0x108
#define CLK_GPIOF   0x20
//---GPIO-F REGISTER---//
#define PORTF_DATA  (*((volatile unsigned long *)0x40025038))   //offset of DATA register for PF1, PF2, PF3 is 0x38 [PF7:PF0::9:2]
#define PORTF_DIR   (*((volatile unsigned long *)0x40025400))   //offset of DIR register is 0x400
#define PORTF_DEN   (*((volatile unsigned long *)0x4002551C))   //offset of DEN register is 0x51C
//---PORT-F I/O---//
#define PF1 0x02
#define PF2 0x04
#define PF3 0x08
//---FUNCTION PROTOTYPE---//
void delay(unsigned long);
void main(void)
{
   SYS_CTRL_RCGC2 |= CLK_GPIOF;
   PORTF_DIR |= 0x0000000E;    //set PF1, PF2, PF3 as output
   PORTF_DEN |= 0x0000000E;    //enable PF1, PF2, PF3
   PORTF_DATA = 0;
   while(1)
   {
       PORTF_DATA |= (PF1 | PF2 | PF3);
       delay(1000000);
       PORTF_DATA &= ~(PF1 | PF2 | PF3 );
       delay(1000000);
   }
	//return 0;
}
void delay(unsigned long count)
{
   unsigned long i=0;
   for(i=0; i<count; i++);
}

Credits

Akash Kollipara

Akash Kollipara

0 projects • 12 followers

Comments