You must be prepared to discuss your work at the beginning of your laboratory session on Tuesday, October 21, and to demonstrate your program to your TA during that period. This part of the assignment is worth 15 points.
Each UART defines a block of eight byte-sized ports that the CPU can use for various purposes -- sending and receiving information, controlling the transmission, etc. Click here for a summary of these ports and their functions. The UART documentation describes access to a specific port in terms of a base address for the UART and an index for the desired port. On the MB5, $200000 is the base address for UART1 and $900000 is the base address for UART2. File uart.ah defines symbols UART1 and UART2 as these addresses.
Figure 2.10 on page 46 of the text shows that the MC68000 chip has 23 address pins and 16 data pins. The address space consists of 224 bytes, which is 223 words. Thus when the MC68000 accesses memory or an I/O device, it specifies a word address and uses the 16 data pins to transmit or receive the data in that word. Byte transfers are possible because two of the five bits labeled ``I/O Transfer'' in Figure 2.10 are used to indicate which data bits are valid. One of these bits is 1 if data bits 0-7 are valid, the other is 1 if data bits 8-15 are valid.
When the CPU accesses a particular port of a particular UART, the 23 address lines must select both a UART chip and a port on that chip. In the MB5, chip select is done by the most significant four bits of the address and port select by the least significant three bits. Data bits 0-7 are always used to transmit information. Thus a CPU program has two ways of accessing a port: by using a word operation and specifying ((base address)+2*(port index)) as the address, or by using a byte operation and specifying ((base address)+2*(port index)+1) as the address. We have defined symbols for the port indices in file uart.ah under the assumption that byte operations will always be used to access the UART.
Communication with the UART device interface is illustrated in the comset.src file.
Two ASCII characters, CR and LF, are used to position the cursor to the beginning of a new line. The need for two characters originated in the use of mechanical devices for printing: CR moved the print head to the beginning of a line, and LF advanced the paper. Distinct characters were needed to support an ``overstrike'' capability, so that characters could be underlined and composite characters (such as a ``cent'' sign, consisting of ``c'' overstruck with ``/'') could be constructed.
The two-character legacy lives on in Windows text files, which are based on MS-DOS conventions. A ``newline'' is represented in such files by the CR followed immediately by the LF. Unix uses only a single character, LF, to indicate ``newline''; Apple Macintosh conventions also dictate a single character, but it is the CR.
Tera Term can be configured to handle either Windows or Macintosh conventions, but not Unix conventions. Select Terminal from the Setup menu, and then choose appropriate values in the Receive and Transmit pull-downs under Newline. Your Receive choice dictates the typed characters that will be recognized as defining a new line, and your Transmit choice dictates what characters will be sent out the HP's serial interface when a new line is recognized in typed input. (The Enter key produces CR and Ctrl-J produces LF.) A reasonable choice is to use CR for Receive and CR+LF for Transmit.
You can use vim to convert text files between the three formats. When you have the file in vim, simply give one of the following commands before writing it out:
The driver program that has been supplied uses both of the MB5's UARTs, and therefore the COM1 port is not available for use by the XRAY monitor. You might want to develop your own driver for testing purposes, using only the COM2 port. Once your character I/O routines are working, you can link them with the supplied driver to actually run the application.
When you have established a COM2 window and completed any testing that you want to do using the XRAY monitor, make a file suitable for downloading via the MooseLoad. This program must use the driver supplied in the zip file. Download this file over the COM1 port. After you have started the program, and MooseLoad has typed ``Executing.....'', select Terminal from the Setup menu of the COM1 window, check the Local echo box, and click OK.
Now type characters into the COM1 window. The characters you type will be echoed in the COM1 window, and should also appear in the COM2 window until you type Ctrl-d. Any futher characters will echo in the COM1 window, but will not appear in the COM2 window.
Ctrl-d switches the direction of communication. After typing Ctrl-d, use the HP's mouse to move the cursor into the COM2 window and left-click to make the COM2 window active. Now when you type characters into the COM2 window, they will appear in the COM1 window. You can switch back and forth as many times as you like, with the Ctrl-d giving up control to the other window.
Typing Ctrl-c terminates the program. The MooseLoad menu will be displayed in the COM1 window, and you can restart the program if you like.
| Instructor | Revision 1.39 (2007/08/27 00:15:44) |