Tiva Lab 01: Blinking LEDs

Introduction

In the realm of embedded systems, visual feedback is often essential. As simple yet effective electronic components, LEDs provide immediate visual feedback and serve as a fundamental tool for developers to understand and debug their systems. The Tiva LaunchPad, equipped with onboard LEDs, offers a practical platform for beginners and advanced users to dive into the world of embedded programming.

This lab will immerse you in the foundational aspects of programming the Tiva LaunchPad boards. We will explore the intricacies of the Keil IDE, which is pivotal for Tiva development. Hands-on exercises teach you how to create a new C project, harness the power of #define statements to streamline your code, and gain proficiency in GPIO configurations for output operations.

Furthermore, we delve into the realm of bit-wise operations, a cornerstone for low-level programming, enabling you to manipulate specific bits for various applications, particularly for controlling the onboard LEDs of the LaunchPad. As an outcome of this lab, you'll achieve mastery in configuring and controlling the blinking rate of LEDs, providing a solid foundation for more complex embedded applications in the future.

Armed with the knowledge from provided reading materials and guided exercises, you'll understand the technical aspects and appreciate the significance of infinite loops in embedded systems and the uniqueness of embedded microcontrollers compared to personal computers.

Join us as we embark on this enlightening journey, exploring the capabilities of the Tiva LaunchPad and unveiling the magic of embedded programming!

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.

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

Required Reading Material

Overview

The Tiva launchPad has rows of connectors along both sides that are used to 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 on the board. Those can be used on your embedded applications. When you first time connect the board to a USB plug, the onboard LEDs may already blink. 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 change the rate at which it blinks.

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

Circuit / Schematic 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 pins on the microcontroller.

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 pin 1 and pin 3 as outputs.

Procedure & Experiments

In this lab, you will learn how to create a C project for the Tiva LaunchPad board and configure the GPIO ports to blink the onboard LED.

* Before doing this lab, you must first study "Lesson 07: Create an ARM C Application with Keil μVision MDK-ARM".

  1. Please create a new folder under the EE3450 folder and name it Lab01_BlinkingLEDs_1. Then, double-click the folder you just created to jump into it.
  2. Launch the Keil μVisio, create a new project, and save the project as Lab01_BlinkingLEDs_1.
  3. Create predefined symbolic constants for the GPIO configurations.
  4. Copy-paste the following code to your main.c file.
  5. Modify the Setup_GPIO() function based on the Pin Configuration Table (table 2 or 4) to configure the onboard switches and LEDs.
  6. Inside the while(1) loop, the commands first of all 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 code must have a main() function, which is the entry point for the system. In the main() function, the line while(1) is the most popular used in an application for embedded microcontrollers. 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 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 been executed on a personal computer, it returns control to the computer's operating system when the program is finished. 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 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, which is 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?
© 2024 Air Supply Information Center (Air Supply BBS)