Lab 7. Serial Communication via UART© Solution

$30.00 $24.00

Preparation You will need a LaunchPad and a laptop/computer with Keil uVision5 installed. Download the Lab7 starter project from Canvas. You will also need to download PuTTY or a similar tool. Starter project Lab7 Purpose The purpose of this lab is for you to gain experience using the UART serial communications protocol. Introduction In this…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Description

5/5 – (2 votes)

Preparation

You will need a LaunchPad and a laptop/computer with Keil uVision5 installed. Download the Lab7 starter project from Canvas. You will also need to download PuTTY or a similar tool.

Starter project Lab7

Purpose

The purpose of this lab is for you to gain experience using the UART serial communications protocol. Introduction

In this experiment, you will be modifying a given source project in C for a clock. Most of the functionality has already been provided. You will need to add some of the UART functionality. When completed, the program will ask you to select a mode of operation, either start time at 0 or enter a start time in seconds. The program will then update the time every second. The time will be displayed in a PuTTY terminal.

Program Operation Overview

The fully functioning program will operate as follows: first the program will ask you to press ‘0’ to start the clock at time 0 or ‘1’ to enter a specified start time in seconds. The function that reads your specified time is not very robust. Pressing any key other than a number (including backspace) will result in undefined behavior. The program uses the global variable g_seconds to track the number of seconds that have elapsed. This value will be incremented every second via SysTick interrupts. The program should then output the time in the format hh:mm:ss updating every second.

Resources

PuTTY – An open source program that will allow serial communication between your board and your computer. You can download the installer file or a copy of the executable from the following link: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html. You will need to configure your connection when you first launch PuTTY. Choose Serial as your connection type. Next, select your COM port and a speed of 9600. You can determine the COM port by checking your Device Manager to see which one your board is connected to. A terminal window will be launched after clicking “Open”. This will be the interface through which you can send and receive UART communications with the board.

ASCII – A type of character encoding in which a numerical value is used to represent a specific text character. For example, the character ‘1’ actually has a numerical decimal value of 49. You may find it useful to use an ascii table for the last part of this lab. You can find one at this link (http://www.asciitable.com/) or you can use the one at the end of this handout.

UART – There are a number of materials available under the UART section of our main course page on Canvas. UART.pdf contains slides describing its operation. UART Notes.pdf provides a description of the steps required to configure UART. Lastly, the video “C11 3 UART code” provides a walkthrough of writing the code required to use UART.

Procedure

1. Begin by running the provided software project. Download the project, unzip the folder, and open the Keil uVision project file. Compile the project and load it on to the Tiva Launchpad Development board. Now open the device manager and determine the COM port associated with the board (Stellaris Virtual Serial Port). Launch PuTTY and open a serial connection with the COM port for your board and 9600 Baud.

You now need to complete the InitConsole() function to initialize UART0. If done correctly, the PuTTY terminal should display a message stating that you have completed the first part of the lab. Demonstrate this to the TA and explain how you determined what value to use on each line.

 

1
EE/CPE 287 Lab 7
Lab Time_______________________ Name_____________________________

Signature_______________________________ Date_________

2. Next, the program will give you some options and allow you to choose the one you want. You need to complete the function myGetChar() for the program to be able to correctly record your input. When called, myGetChar() should block until any key is pressed. It will then return the ASCII value corresponding to that key. Your program will advance when you press either ‘0’ or ‘1’. It will respond with a warning message if any other key is pressed. The program will notify you that you have completed Part 2 after you press ‘0’ or ‘1’. Demonstrate this to the TA and explain how your code works.

Signature_______________________________ Date_________

 

3. Lastly, you will change the PrintTime() function so that the displayed time is continuously overwritten rather than displayed on a new line. The time is tracked in seconds by the global variable g_seconds. The time should be displayed in the format hh:mm:ss (assuming a 24 hour clock). Rather than using one of the provided UART STDIO functions such as UARTprintf(), you should complete myPutChar(). You will need to call myPutChar() multiple times inside PrintTime() since it can only output a single char at a time. Demonstrate your program’s correct functionality to the TA and explain how your code works.

Signature_______________________________ Date_________

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

2
EE/CPE 287 Lab 7

Lab 7. Serial Communication via UART© Solution
$30.00 $24.00