Lab 9

Asynchronous Serial Communications

Before the Lab

Asynchronous serial interfaces are used to interface a microcomputing system with serial devices. The most common of these is a terminal. Initially, computer systems were interfaced serially with TTL networks involving 50 chips or so and costing several hundred dollars. With the advancement of LSI circuits, UARTs (Universal Asynchronous Transmitter/ Receivers), which were reasonably intelligent shift registers, were introduced. This reduced chip count to about ten and cost to under $100. Development of peripheral devices for specific microprocessor families improved the situation even more. The UART interfaces directly with the microprocessor bus, and requires minimal supporting circuitry. The cost of serial interfaces is now very low.

In this experiment you will use the independent DUART(Dual UART) chip interfaced with the processor on the HC11-VDK board. This interface has accessible registers that can be used to configure it and to find out about its status when needed. The base address of the DUART registers is $4000.

In the HC11-VDK environment, the DUART generates interrupts on the IRQ request line.

  1. Your first assignment is to write a replacement of the function in the BUFFALO monitor that writes a sequence of characters to a terminal. Your function should configure the DUART and write the ASCII code pointed to by the Y register to an auxiliary terminal; the write is terminated with an $04 (EOT) character. This code module should be interrupt-driven, so that the processor could implement foreground tasks during the write. This will require initializing your program to handle interrupts. Your interrupt service routine should make sure that the source of the interrupt is correct.

  2. Your second assignment is to write a replacement of the function in the monitor that accepts ASCII characters from a terminal. The function is called whenever you wish to accept a character and the systems "hangs" until a character is typed. Note that a character echo is required. This module need not be interrupt driven, since the system "hangs" while waiting and can not do anything anyway. The character typed is returned in accumulator A.

  3. Finally you should put all of this together by writing a program that accepts characters and stores them in a buffer until a carriage return is detected. The program then types out the contents of the buffer to screen, every 500 milliseconds, ten times. Obviously, this procedure is simplified if you make use of your earlier efforts.

In the Lab

Load and test all of your programs. You will use the additional terminals available in the lab to test the first program. The communication setting for these terminals is as follows:

9600 baud rate
8 data bits 
1 stop bit
0 parity bits

NOTE THAT IN THE PAST THIS LAB HAS TAKEN A LONG TIME TO COMPLETE; MAKE SURE THAT YOU COME PROPERLY PREPARED.

After the Lab

Produce clean, annotated listings of all your programs. Currently, the maximum baud rate commonly used is 19,200. Calculate the overhead (i.e., percentage of time a computer is engaged in a task) for acceptance of characters and storage in a buffer for inputs of this speed. Would it make sense to make your character-accept program interrupt-driven? (Don't forget to include interrupt-processing overhead). What is the maximum feasible baud rate for a HC11-VDK board?

Helpful hints

Here's the setup for the printing program:

	ldx     #DUART
        ldaa    %#00000001	* generate ints. from TxRDY
        staa    IMR,X
        ldaa    #%00001011	* set 9600 baud transmitting
        staa    CSRA,X
        ldaa    #%01100000	* Choose external clock
        staa    ACR,X
        ldaa    #%00010110      * Force pointer to MR1, Enable
        staa    CRA,X           *  the transmitter only
        ldaa    #%00010011	* Set mode to 8 bits, no parity
        staa    MRA,X              
        ldaa    #%00001000      * Set stop bits
        staa    MRA,X

And for the receiving program:

        ldx     #DUART
        ldaa    %#00000000      * generate ints. from TxRDY
        staa    IMR,X
        ldaa    #%10110000      * set 9600 baud receiving
        staa    CSRA,X
        ldaa    #%01100000      * Choose external clock
        staa    ACR,X
        ldaa    #%00011001      * Force pointer to MR1, Enable
        staa    CRA,X           *  the receiver only
        ldaa    #%00010011      * Set mode to 8 bits, no parity
        staa    MRA,X
        ldaa    #%00001000      * Set stop bits
	staa	MRA,X

Recall that in the receiving program, you will not use interrupts. Instead, your subroutine must poll the status bit of the receive hold register. Don't forget to check the status flag for TxRDY when you enter the ISR as follows:

irqisr  
        ldx     #DUART
        ldaa    SRA,X
        anda    #%00000100              * check the status flag
        beq     return
        .
        .
        .

Miscellaneous Hints

  • Always mask off the high bit of your characters before sending and after receiving:
  • Get your printing program to work with one character, then try to print a whole line. The same goes for the receiving program. Get it to receive one character, then worry about reading in a whole line.
  • Bring your DUART data sheet to lab!!
  • Smile! Only one more lab to go!

 


| EE-218  Homepage | Syllabus | Schedule | Lab News | Faculty | Contact Information | Lab Info | Project |


Department of Electrical Engineering and Computer Science
Box 1824 Station B
Nashville, TN 37235
Phone: 322-2771
Fax: 343-6702


 | Search | Site Index | People Finder | Phone Directory | VUnet | VUmail | VU Library | Help |


Last Updated: Saturday, March 05, 2005

Juan J. Rodriguez-Moscoso

Copyright © 2003 Vanderbilt University