Tiva Lab 02: Simple GPIO Control

Objective

  • Understand I/O operation in Tiva TM4C LaunchPads
  • Learn the steps of GPIO configuration on Tiva TM4C LaunchPads
  • Learn how to read data from the input pin, and write a data to output pin

Required Reading Material

Background Information

GPIOs are the basic interfaces of any microcontroller. For a positive logical system, a GPIO pin can be set high (taking the value 1) by connecting it to a voltage supply or set low (taking the value 0) by connecting it to the ground. The Tiva LaunchPad can set the GPIO pin to take either value and treat it as an output, or it can detect the value of the pin and treat it as an input.

You will learn how to write a C code to configure the GPIO ports, read the status of switches, and turn on/off the LEDs.

The first important thing for this lab is the GPIO configuration. When the processor has started executing, but before you can run application software on the processor, it must be initialized, including loading the appropriate software-configuration. The "Lesson 10: GPIO Ports and Configurations"describes the detailed steps that the software must take to initialize the GPIO Ports after reset.

 

Requirements

Now, a customer asks you to remodel his house. He wants to use an embedded system to control all lighting systems in the house, including doorbells. Three types of control systems could be used in a home:

  1. A button controls a device, such as a doorbell: when the user presses the doorbell button, the system triggers the doorbell until the button is released.
  2. A switch controls a light set: when the user presses the switch, the light is on. Press again to turn off the light.
  3. Multiple switches control lighting sets, such as the stairwell lighting control system: The switches are installed on the first and second floors near the stairs. When the user presses any switch, the light is on, pressing any switch again to turn off the light.

Required Components List

Button Small 64 Push Button (Switch) × 4
Resistor 64 220-ohm Resistor × 3
LED Green 64 LED × 2
Trnasistor 64 S8050 NPN Transistor × 1
ActiveBuzzer 64 Active Buzzer × 1
breadboard s Breadboard × 1

Circuit / Schematic Diagram

Then, you will create a prototype system to simulate all three types of control systems. The prototype circuit is shown below.

You have to place all the components on the breadboard and use wires to connect the components to the Tiva board. The main functions you must implement are as follows.

  • The SW1 is used to control the buzzer (doorbell).
  • The SW2 is used to control LED1
  • The SW3 and SW4 are used to control LED2, which is installed on the stair.

Procedures

Create a new folder under the EE3450 folder, named it as Lab02_GPIOControl. Launch the Keil μVision IDE, create a New Project and save the project to the folder you just created. Add MyDefines.h to the Source Group.

Sample Source Code

Copy the following code to your main.c file.

GPIO Configurations

Implement the Setup_GPIO() function to initialize the GPIO Ports based on the PIN Configuration table.

Lab Experiments