You are on page 1of 2

Embedded Systems Lab

Experiment-1: Interfacing GPIO ports with LED and switch


Objectives: To get familiarized with Tiva C Series TM4C123 LaunchPad Kit
Equipment and components needed: LaunchPad kit, Laptop PC (use personal)

Fig 1: Board description

Fig 2: LED and switch interface circuit diagram

1
Important registers required for experiment
SYSCTL_RCGC2_R; // 1) activate clock for Port F

GPIO_PORTF_LOCK_R = 0x4C4F434B; // 2) unlock GPIO Port F

GPIO_PORTF_CR_R = 0x1F; // allow changes to PF4-0

// only PF0 needs to be unlocked,

GPIO_PORTF_AMSEL_R // 3) disable analog on PF

GPIO_PORTF_PCTL_R // 4) PCTL GPIO on PF4-0

GPIO_PORTF_DIR_R // 5) PF4,PF0 in, PF3-1 out

GPIO_PORTF_AFSEL_R // 6) disable alt funct on PF7-0

GPIO_PORTF_PUR_R // enable pull-up on PF0 and PF4

GPIO_PORTF_DEN_R // 7) enable digital I/O on PF4-0


Delay function:

void Delay(void){unsigned long volatile time;

time = 145448; // 0.1sec

while(time){

time--;

Exercise 1: Toggle onboard LED (R or G or B). Observe the waveforms in debug mode and
calculate on time, off time and frequency.
Exercise 2: Toggle onboard LED in sequence (R, G, B). Observe the waveforms in debug mode
and calculate on time, off time and frequency.
Exercise 3: Interface SW1 and control LED (R or G or B). Observe the waveforms in debug mode
Post-lab experiment:
Write a program for performing the following operations:

Event Action in RGB LED


SW1 pressed Yellow color blinking
SW2 pressed Pink color blinking
SW1 and SW2 pressed White color blinking
No SW pressed LED off

You might also like