Starting from:
$30

$24

Lab 5. Bit-Specific Addressing and External I/O © Solution


Preparation

You will need a LaunchPad and a laptop/computer with Keil uVision5 installed. Download the Lab5 starter project from Canvas. You and your partner will be provided with three LEDs, five resistors, and two pushbuttons.

Starter project    Lab5

Purpose

The purpose of this lab is for you to become familiar with using bit specific addressing to access GPIO ports on the Tiva board. You will use external LEDs and pushbuttons connected to GPIO ports D and E.

Introduction

The previous lab required you to read from or write to the entirety of the Data Register for Port F. That method requires some additional steps to prevent overwriting values on all of the pins. For this lab you will use bit-specific addressing to specify specific pins. Bit-specific addressing requires you to locate the base address associated with a desired port and then add offsets to specify which pins you wish to access.

Procedure

    1. Using the provided components, connect LEDs to PE5, PE4, and PE3 as positive logic and connect pushbuttons to PD1 and PD0 as negative logic. Demonstrate this to the TA.

Signature_______________________________    Date_________

    2. Complete the initialization functions “PortD_Init” and “PortE_Init” so that PD1 and PD0 are initialized as inputs and that PE5, PE4, and PE3 are initialized as outputs. As with the last lab, your initialization functions should be coded in a way that does not affect any pins that were not previously specified (i.e. use “&=” and “|=”). Port D will be used to interface with two pushbuttons and Port E will be used to interface with three LEDs.

Using bit specific addressing, write functions for turning on and off the LEDs connected to Port E. The design of these functions is up to you. Check the next part of the lab to determine what functions you wish to write. For example, you could write individual “on” functions for each LED or ones that can turn on multiple LEDs in a specific pattern. You must write an off function that turns off all three LEDs. Write another function that returns the states of the pushbuttons on Port D. Demonstrate your functions to the TA.

Signature_______________________________    Date_________

    3. Now you will use the previous functions to create a more complex system. When one of the pushbuttons is pressed the LEDs should blink in a pattern that simulates counting from 0 to 7 in binary (000, 001, 010, 011, 100, 101, 110, 111). When the other pushbutton is pressed, the pattern should alternate between 010 and 101 until that pushbutton is pressed again. The LEDs should otherwise be off if one of the blinking routines is not active. If your program is not responding correctly to button your pushes, try using the debugger. If it works correctly in the debugger, but not in real time then consider what the major difference is between the two. Modify your code to take this into account. Demonstrate your code to the TA and then return all provided components

Signature_______________________________    Date_________

1
EE/CPE 287 Lab 5

More products