18-348 Lab #10

Fall 2007

Pre-lab due: Friday, 10/05/2007
Lab demos: week of 10/08/2007
Lab handins due:  Friday, 10/12/07

Links to all files referenced in the lab and prelab can be found in the Files section at the end of this document.

We strongly recommend you complete this lab (except for the actual in-lab demo) by 6 PM on Monday -- i.e., before the official lab demo times and before the in-class test. Completing this lab will help you understand serial communications, and you can be sure that topic will appear on the test!

Change -- 8 Oct 2007: We have released a new version of the serialcomm zip file. The demo.txt file within the zip file has been changed to accommodate a change in the way lab groups are numbered this year. It is important that you use this new version for your lab demo. Link: SerialComm


Pre-Lab:

Goal:

Discussion:

Refer to Chapter 13 of the MCU9S12 Datasheet for details of the Serial Communication Interface.  Refer to the lecture notes for details on serial communication.

Procedure:

Part 1:

Study Sections 13.3 and 13.4 of the MCU9S12 Datasheet.

For each table below, fill in the values from the corresponding list (Hint there are the same number of values as locations in the table.  Each value should be used only once).

Table 1:

Register
Value for this bit = 0
Value for this bit = 1
SCICR1 bit 7


SCICR1 bit 6


SCICR1 bit 5


SCICR1 bit 4


SCICR1 bit 3


SCICR1 bit 2


SCICR1 bit 1


SCICR1 bit 0


Values for table 1:
(copy each phrase below into exactly one box above)


Table 2:

Register
Value for this bit = 0
Value for this bit = 1
SCICR2 bit 7


SCICR2 bit 6


SCICR2 bit 5


SCICR2 bit 4


SCICR2 bit 3


SCICR2 bit 2


SCICR2 bit 1


SCICR2 bit 0


Values for Table 2:


Table 3:

Register
Value = 0
Value = 1
SCISR1 bit 7


SCISR1 bit 6


SCISR1 bit 5


SCISR1 bit 4


SCISR1 bit 3


SCISR1 bit 2


SCISR1 bit 1


SCISR1 bit 0


Values for Table 3:


Part 2:

Review section 13.4.2. of the MCU9S12 Datasheet on baud rate generation.  Note that the values in table 13-10 are incorrect for our purposes because they assume a module clock rate of 25 MHz, and the module clock is 8 MHz.

Using the formula given, fill in the SCIBR[12:0] values required for each of the listed baud rates below.  Compute the actual baud rate (using the formula and the integer value you chose for SCIBR.  Compute the % error using the formula:
100 * (Actual Baud Rate - Nominal Baud Rate) / Nominal Baud Rate

Table 4:

Nominal Baud Rate (bits / sec)
SCIBR value (decimal representation)
Actual Baud Rate (bits / sec)
Error (%)
300



600



1200



2400



4800



9600



14400



19200



38400



56000



115200



Questions:

  1. (10 points) Complete Table 1 from part 1.
  2. (10 points) Complete Table 2 from part 1.
  3. (10 points) Complete Table 3 from part 1.
  4. (20 points) Complete Table 4 from part 2.

Hand-in Checklist: (50 pts)

All non-code submissions shall be in a single PDF document.

  1. (50 pts) Answers the the questions above.

Refer to the LAB FAQ for more information on lab handin procedures and file type requirements.  You MUST follow these procedures or we will not accept your submissions.


Lab 10

For this lab, you will establish serial communication with a PC.  We have written a simple program which reads a query string from the serial port, looks for the query in a string file, and returns a response string over the serial port.  The program uses the following protocol: 

Your program must be able to follow this protocol when it sends or receives data from the PC.

In addition to the PC software, you will use an LCD library to display output on the onboard LCD. The readme that accompanies lcd_lib-1_2.zip contains information about how to use it.

Procedure:

Part 1: PC serial program.

  1. Determine the address of the serial port (in Windows XP) by doing the following:
  2. Download the SerialComm program.  The zip file contains a sample string table file, the executable, and several supporting DLLs.  The DLLs must be in the same directory as the executable..  You can obtain the command line syntax of the program by running it with no arguments.

Part 2: Hardware and Software

  1. Wire the board according to the comments in the skeleton file.  Be sure to check the jumper settings in the lcd_lib readme file.
  2. Download the lab 10 skeleton file and lcd_lib.zip.
  3. Start a new C project.  Rename the skeleton to lab_10_gXX.c and replace the main file with it.  Add the lcd_lib.h and lcd_lib.c files.
  4. Implement the serial communications by filling in the TODO sections of the program.  The program must meet the following requirements:

Part 3: Run the system

  1. Test your program by connecting the DB9 port on the CSM12C32 module with the serial port on the PC.  Run the SerialComm program using the demo.txt and initiate a communication.
  2. Write out the byte-by-byte values of the query and response communications.  The default groupString has been done below as an example.

Bonus -- Part 4: Communication Speeds

This portion of the lab is optional.  Try the communication at each baud rate, starting at 300 baud and working up.  Record the fastest baud rate that you can successfully communicate at and the slowest baud rate where communication fails (usually with a frame error on the PC).  Note that you will have to demo these two speeds to the TA, so if you are doing the part of the lab on a computer other than one in the lab, you must be able to bring the computer with you to lab for the demo.  Note that you MUST successfully demo the values recorded in your prelab in order to receive any bonus credit for the writeup.

Demo Checklist: (40 + 8 points)

For the demo, the TA may ask you to use a different string file.  The query string will always be your lab number (e.g. "1A" in ASCII characters).  Response strings will never be longer than 8 characters.

  1. (20 points)  Demo successful communication between the PC and the computer at 2400 baud.
  2. (20 points)  Demo successful communication between the PC and the computer at 9600 baud.
  3. (8 points)  (optional bonus) Demo your findings for the bonus (fastest baud rate with successful communication and the slowest baud rate where communication fails).

Hand-in Checklist: (50 + 10 pts)

  1. (5 points) List any problems you encountered in the lab and pre-lab, and suggestions for future improvement of this lab. If none, then state so to get these points.
  2. (20 pts) Submit your completed C implementation (as lab_10_gXX.c).  Your code must conform to the course style sheet to receive full credit.
  3. (25 points) Record the byte-by-byte query and response (using your own group name) from part 3.
  4. Bonus: (10 pts) (optional) List the fastest baud rate with successful communication and the slowest baud rate where communication fails from part 4.

Refer to the LAB FAQ for more information on lab handin procedures and file type requirements.  You MUST follow these procedures or we will not accept your submissions.


Hints and Suggestions:

FILES for this lab:

Relevant reading:

Also, see the course materials repository page.