Iowa State University

CPRE 288 Laboratory


Lab 5: Serial Communications Using UART

Lecture - Lab Connection

In lecture, you have studied the use of the UART. In this lab, you will use the UART to perform simple serial communication with your desktop computer.

Prelab 

  • Read the lab description as well as the data sheet for the TM4C123GH datasheet related to UART. Tiva TM4C123GH6PM datasheet
  • Draft the code. The code need not be complete, and you don't have to compile or execute it before coming to the lab. Attempt to draft some code to show your TA.
  • Print the Lab Evaluation Form, so that your TA can check off work performed during this lab session.

Answer the following questions in preparation for the lab (refer to the Tiva datasheet (datasheet)and/or textbook as needed):

  1. What UART registers are relevant to this lab? [2 points]
  2. What is the value to be loaded into the IBRD and FBRD registers for a baud of 9600? [2 points]
  3. How many UARTs are there on the TM4C123GH6PM? Which one will you use to communicate between the microcontroller and your Desktop computer? (read below) [1 point]

Reference Files

Download the following files to your project folder on your U: drive.

  • timer.c/timer.h: The file that contains utility functions for the cyBOT platform.
  • lcd.c/lcd.h: The program file with a number of LCD functions.
  • uart.c/uart.h: Skeleton code for you to implement.

WiFi board UserGuide: UserGuide

Serial Communication

As the term serial implies, information is sent as a sequence of signals.  Signals are grouped together to form serial frames.  Serial frames can contain 5 - 8 bits of payload and have bits to distinguish the start and end of a frame.  There is also an additional bit available to provide parity.  Parity provides simple error detection over a communication medium that may be noisy.

The rate at which the sequence of signals is sent is called baud.  The term represents the number of distinct symbols transmitted over a medium per second.  A symbol may actually represent more than one 1 bit of digital information. The term baud is very closely associated with serial communication and you will find this term used in the TM4C123GH6PM datasheet.

In order to communicate successfully between the cyBOT platform and your lab PC, a number of standards need to be in place.  The cable you will be attaching to the cyBOT's base board with its male DB-9 connector and the signaling used over that cable all comply to standards.  The signaling standard is RS-232.  There is an integrated circuit on the ISU base board that provides the RS-232 compliant signaling.  In RS-232 parlance your PC is a DTE (Data Terminal Equipment) and the cyBOT's interface is configured to be a DCE (Data Circuit terminating Equipment).  All of these standards and conventions are transparent to your programming effort.

The objective of this lab is for you to become familiar with configuring and using a UART.  This is a common element in microcontrollers.  UART4 is dedicated to interfacing with the Create. For those of you familiar with networking and the ISO OSI reference model, this lab is having you configure and use a rudimentary data link layer laid over a physical layer provided by RS-232 and the serial cable.

Communication requires two or more participants. The opposite end of the cyBOT will be your lab PC, but to be precise you will use Putty to facilitate communications from the PC end. This program is able to talk directly to the serial port (i.e. COM1) of your PC. As you type characters, ASCII characters will be sent over the serial connection.

For all parts of this lab, you are to configure Putty to communicate with your cyBOT platform with the following parameters:

  • 9600 speed (baud)
  • 8 Data bits
  • No Parity
  • 1 Stop bits
  • No flow control

Naturally, the UART on the cyBOT will have to be configured to communicate with these same parameters.

Note #1 - In the Terminal section of Putty you can Force local echo so you can see what you type.

Note #2 - In the Session section of Putty, you can select "Default Settings" and click Save so you do not have to reconfigure each time you open the program.


Lab 5 Description

  • Lab 5 Manual: A detailed description of the objectives to complete for Lab 5

Cautions

Turn the power to the Cerebot board and iRobot off before charging. The Cerebot board consumes power and the battery will not charge if the robot is in full_mode (which it enters after calling oi_init, turing the power LED yellow). The robot is charging when the robot's power LED is pulsing red and both green LEDS on the dock are lit.

Reference Files

Files Description
Tiva TM4C123GH6P datasheet.pdf Information about the TM4C123GH6P
Documentation on printf Documentation for the lprintf and printf function.
Lab Evaluation Form Evaluation form for Lab
Online Feedback Form Tell us what you think of the lab (feedback forms)