CE-2800 Embedded Systems Software
Lab 5: Serial Communications via the USART

Objectives

Assignment

In this assignment, you will be writing an assembly program that uses the USART to receive characters from your PC (via the RealTerm application) and, as each incoming character is received, immediately transmit that same character back to the PC, where it will be re-displayed within the RealTerm application.

You may use the USARTDemo program code as a reference for a program (in Lab5.asm) that contains only a "main" body of code which does the following, as illustrated by the flowchart:

Within your Lab5.asm file, you must .INCLUDE a file named rs232_dd.asm, which you must write. This file will contain a number of subroutines as illustrated by the following UML class diagram:

The subroutines in this file are to be written according to the following "interface" specifications:

rs232_init

This subroutine initializes the USART, enabling it to both transmit and receive, with the configuration specified by the values of the registers indicated in the table below.

Baud Rate (R25)

The baud rate that is to be used.  The baud rate values specified via R25 are as follows:

R25=0 -> 2400 baud,
R25=1 -> 4800 baud,
R25=2 -> 9600 baud,
R25=3 -> 14.4kbaud

Frame Length (R23)

The number of bits within the data frame, specified via R23 as follows:

R23=0 -> 5 bits
R23=1 -> 6 bits
R23=2 -> 7 bits
R23=3 -> 8 bits

Parity (R21)

The parity setting specified via R21 as follows:

R21=0 indicates no parity. 
R21=2 indicates even parity.           
R21=3 indicates odd.  Anything else is undefined.

Return Value: None 

rs232_sendByte

This subroutine transmits a single byte.  The byte that is to be sent is passed in as a parameter specified via R25. 

Return Value: None

rs232_recByte

This subroutine receives a single byte. This call is blocking; that is, it waits in a loop until a byte is received.

Parameters None

Return Value via R25: The byte that was received.

rs232_recMessage
rs232_sendMessage

These last two subroutines will not be implemented fully in this lab assignment. For now, just make each one return immediately.

EVERY subroutine must have the following format:
;****************************************************************************************************************
;subroutine sub1
; This subroutine <explanation follows>.
; Describe the arguments passed to the subroutine via registers.
; Describe the return value returned by the subroutine via a register
sub1:
     <register save to stack>
    <code>
    <register restore from stack>
    ret
;***************************************************************************************************************

Note that you do not have to use the "delay.asm" subroutine supplied with the example code. It is there to help you understand how subroutines can be constructed to accept arguments and pass return values via registers.

Demonstration

You must demonstrate your working program on your board before the submission date.

Lab Submission (due 11:00pm, Tuesday, January 17, 2012)

For your submission, you need only supply your working, fully commented Lab5.asm and rs232_dd.asm files.

Upload your submission through Blackboard (assignment "Lab 5").

Be sure to keep copies of all your files, in case something gets lost.

Grading

Your lab grade will be determined by the following factors:

Program - comments and formatting are important aspects of assembly language programming! And it has to work correctly.

Timeliness of submission as stated in the course policies.