Tiva Lab 01: Blinking LEDs

This lab introduces the fundamentals of embedded programming using the TI Tiva LaunchPad series. Participants gain practical experience with the Keil μVision IDE, GPIO configurations, and bit-wise operations by developing simple firmware to blink onboard LEDs. The lab reinforces the importance of infinite loops in microcontroller applications and lays the groundwork for more complex embedded projects.

Introduction

Embedded systems rely on simple components, such as LEDs, to provide immediate visual feedback and facilitate debugging. This lab uses the TI Tiva LaunchPad boards (EK-TM4C123GXL and EK-TM4C1294XL) to demonstrate core embedded programming concepts. Participants will explore the Keil μVision IDE, practice setting up C projects, and learn how to manipulate GPIO pins using #define statements and bit-wise operations. The lab underscores the importance of continuous loops (e.g., while(1)) in embedded applications, which run independently of an operating system.

Objective

  • Project Setup with Keil IDE: Familiarize with the Keil IDE by creating a new C project tailored for the TI Tiva LaunchPad Boards.
  • Code Optimization with #define: Utilize #define statements to make the code more understandable and efficient.
  • GPIO Configuration Mastery: Learn to set up and control GPIO for output operations, specifically for LED control.
  • Bit-wise Operations: Grasp the usage of bit-wise operators to manipulate specific GPIO pins, turning LEDs on or off.
  • LED Feedback Control: Reprogram the Tiva board to alter the blinking behavior of its onboard LEDs.
  • Understanding Infinite Loops: Comprehend the significance of the "while(1)" loop in embedded systems and its necessity for continuous operation.

Required Reading Materials

Components Required

Component/DeviceDescriptionQuantity
LED Green 64 TM4C1294 onboard Green LEDs (LED1 ~ LED4) × 4
LED Green 64LED Green 64LED Green 64 TM4C123G onboard RGB LED × 1

Background

The Tiva launchPad has rows of connectors along both sides that connect to several electronic devices and plug-in 'shields' that extend its capability. The EK-TM4C123GXL LaunchPad has a single RGB LED on the board, and the EK-TM4C1294XL LaunchPad has four LEDs. Those can be used on your embedded applications. The onboard LEDs may blink when you first connect the board to a USB plug. That is because the boards are generally shipped with the Blink sketch pre-installed.

In this lab, we will reprogram the Tiva board with our Blink code and then adjust the blink rate.

Please follow to learn how to set up the Keil μVision IDE, create a new project, download and debug the code.

Circuit Diagram

The onboard switches and LEDs for Tiva LaunchPads are as shown below:

EK-TM4C123GXL LaunchPad - Circuit

The EK-TM4C123GXL LaunchPad comes with an RGB LED and two user buttons. Table 1 shows how these features are connected to the microcontroller's pins.

TM4C123GXL Pin1 s

Table 1: User Switches and RGB LED Signals

GPIO Pin Pin Function User Device
PF4 GPIO SW1
PF0 GPIO SW2
PF1 GPIO RGB LED (Red)
PF2 GPIO RGB LED (Blue)
PF3 GPIO RGB LED (Green)

Table2: Pin Configurations for TM4C123G

DevicePort.Pin Signal TypePCTLDirectionDrive Mode

In your code, you must configure GPIO Port F, pins 1 and 3, as outputs.

Procedure

In this lab, you will create a C project for the Tiva LaunchPad, add the shared macro header, configure the GPIO port, and blink the on-board LEDs.

Before starting, study Lesson 07: Create an ARM C Application with Keil μVision MDK-ARM, which covers creating a project, selecting a device, and downloading/debugging code.

Part 1 — Create the Project

  1. Under your EE3450 folder, create a new folder named Lab01_BlinkingLEDs and open it. This folder will hold this lab's project files.
  2. Launch Keil μVision and create a new project. When prompted, select the device that matches your boardTM4C123GH6PM for the EK-TM4C123GXL, or TM4C1294NCPDT for the EK-TM4C1294XL. Save the project as Lab01_BlinkingLEDs. (See Lesson 07 for the full walkthrough.)

Part 2 — Add the Shared MyDefines.h Header

About the Common folder. MyDefines.h lives in a shared Common folder (for example EE3450\Common), not inside this lab's folder. Every EE3450 lab reuses the same Common folder, so you type these macros only once and share them across all labs. If you do not have a Common folder yet, create one under EE3450 now.
  1. Type in the MyDefines.h file and save it in your Common folder. Enter it yourself rather than copying it — typing the macros is how you learn them.
  2. Tell the compiler where to find the MyDefines.h header file: open Options for TargetC/C++ tab, and add the Common folder to the Include Paths field. Click OK.
    Keil Options For Target C/C++ Keil Add Common To Include Path

Part 3 — Add the Template Firmware

  1. Copy the provided incomplete main.c template into your project (use the file for your board). Unlike MyDefines.h — which you type in yourself to learn the macros — you simply copy this file: it already contains the boilerplate so you can focus on the two parts you will complete yourself, the Setup_GPIO() function (Part 4) and the while(1) loop (Part 5).

  1. Copy-paste the following code to your main.c file.
  2. Modify the Setup_GPIO() function based on the Pin Configuration Table (table 2 or 4) to configure the onboard switches and LEDs.
  3. Inside the while(1) loop, the commands first turn the LED pin on (high), then delay for 1000 milliseconds (1 second), then turn the LED pin off, and pause for another second.

Every C program must have a main() function, which serves as the program's entry point. In the main() function, the while(1) loop is the most commonly used in embedded microcontroller applications. The line while(1) creates an infinite loop that never stops executing. It executes over and over and over again unless the program is intentionally stopped or there is some condition under this loop that gets met that takes it out of this infinite loop.

Why do embedded programs contain an infinite loop? While personal computers have an operating system, embedded microcontrollers generally do not. Once a program has executed on a personal computer, it returns control to the computer's operating system when it finishes. An embedded microcontroller, however, does not have an operating system and cannot be allowed to fall out of the program at any time. Hence, every embedded microcontroller application has an infinite loop built into it somewhere, such as the line while(1). This prevents the program from running out of things to do and doing random things that may be undesirable.

Lab Experiments

Questions

Read the following datasheet for the EK-TM4C123GXL or EK-TM4C1294XL board, then find the answer to the questions.

  1. The CPU used on the Tiva board is an ARM Cortex-M4-based processor. What is the maximum operating frequency of the processor on the EK-TM4C123GXL and EK-TM4C1294XL boards?
  2. List all external clock sources on your Tiva LaunchPad board.
  3. The onboard In-Circuit Debug Interface (ICDI) supports a UART communication port connected to the Tiva LaunchPad. Which GPIO pins on the Tiva LaunchPad are used for UART communication?
  4. Each Tiva Launchpad has two microcontrollers. What is the purpose?
© 2026 Air Supply Information Center (Air Supply BBS)