Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab 4. Initializing and Using GPIO Ports in ARM Assembly Preparation You will need a LaunchPad and a laptop/computer with Keil uVision5 installed. Download the

Lab 4. Initializing and Using GPIO Ports in ARM Assembly Preparation

You will need a LaunchPad and a laptop/computer with Keil uVision5 installed. Download the Lab4 starter project from Canvas.

Starter project Lab4

Purpose

The purpose of this lab is for you to become familiar with using the GPIO ports on the Tiva board. You will write code that initializes the Port F pins connected to the LEDs and pushbuttons on the board.

Introduction

The Tiva Launchpad uses memory mapping to interface with I/O devices. This means that the actual physical devices such as pushbuttons and LEDs are accessed as if they are normal memory locations. The GPIO ports the pushbuttons and LEDs on the board are connected to must first be initialized before they can be used. Attempting to access GPIO pins that have not been correctly initialized will result in a Hard Fault which will effectively cause the board to stop executing your program. You will be able to see this in the debugger as the board will continually attempt to execute the hard fault handler. You must be very careful when writing to entire ports that you do not touch any pins that you are not directly using. For this reason, you should not use the MOV instruction during this lab.

Procedure

1. Complete the initialization function PortF_Init located in file PortF.s to initialize both of the pushbutton pins as inputs and the led pins as outputs. The figure on page 144 of your textbook can be used to determine what is connected to each pin. This figure can also be found in the appendix section of the online version of the textbook. Do not use the MOV instruction in any of the code you write. All of the LEDs should turn on if the initialization function is correct. Demonstrate this to the TA.

Signature_______________________________ Date_________

2. Now you will create six subroutines in PortF.s with the following functionality: (1) Turn on the red LED, (2) Turn on the blue LED, (3) Toggle the green LED, (4) Turn off all of the LEDs, (5) Return the state of the pushbuttons, and lastly (6) a delay function that is less than a second. You may reuse your delay subroutine from earlier labs or write a new one. Your other subroutines should use Port Fs data register (GPIO_PORTF_DATA_R) and should not use the MOV instruction. Demonstrate to the TA that your subroutines are correct by calling them in the main loop. Your green LED toggle subroutine should be called multiple times to prove that the subroutine is causing the LED to actually toggle. Use the debugger to show that the green LED toggles and that your pushbutton subroutine is returning the correct button state.

Signature_______________________________ Date_________ Lab

3. Use the subroutines from the previous part to write a program with the following behavior depending on which buttons are pressed:

No buttons: Toggle the green LED

SW1 pressed: Blue LED on

SW2 pressed: Red LED on

Both pressed: Blue and Red LEDs on, green LED toggle.

In order to have the green LED toggle at an observable rate you should first call your delay at the start of your program before you check the state of the buttons. Demonstrate your program to the TA.

Main.s File

AREA |.text|, CODE, READONLY, ALIGN=2 THUMB EXPORT Start IMPORT PortF_Init IMPORT LEDs_on ;Be sure to import your created I/O functions

Start BL PortF_Init loop ;Used by Part 1 to prove PortF_Init is correct BL LEDs_on ;Comment out for later parts ;Part 2 ; You can call your created subroutines here ; Part 3 ; Call delay ; Read the state of the buttons ; None -> Call toggle ; SW1 -> Call blue_on ; SW2 -> Call red_on ; Both -> Call toggle, blue_on, red_on

B loop

ALIGN ENDimage text in transcribed

portF. s file 62 30 LT Aaa l.teel, coce, Reace.' ALI2k2 104

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions