RS232C and SPI Serial Communications Interface Lab - Prof. Janos L. Grantner, Lab Reports of Microcomputers

A laboratory exercise focused on understanding and implementing asynchronous serial communications using rs232c and the serial peripheral interface (spi) of the 9s12dp512 microcontroller. Students will build rs232c compatible circuits, establish full-duplex serial communications channels, and develop c programs for data transmission and reception. The exercise covers both single character and string messages, as well as spi communications.

Typology: Lab Reports

Pre 2010

Uploaded on 07/23/2009

koofers-user-0p4
koofers-user-0p4 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Laboratory Ten
Serial Communications Interface
Objectives:
i. To understand the RS232C asynchronous serial communications interface
ii. To use one of the SCI Modules of the 9S12DP512 microcontroller to send and
receive messages over an asynchronous serial communications port
iii. To familiarize with the Serial Peripheral Interface (SPI) Module of the
9S12DP512 microcontroller
iv. To develop a C program that will act as a master/slave for transmitting/receiving
data
over a SPI interface
Task One
You should build a RS 232C compatible asynchronous communications interface on your
breadboard.
Build a RS 232C compatible transmitter and a receiver circuit on your breadboard (use MC 1488
line driver and MC 1489 receiver devices, respectively, or compatibles). First, to verify your
circuit, place a short-circuit between the RS 232C output and input terminals. Develop a program
that will configure the associated Port S bits as input and output, respectively. Your program
should then prove that your RS 232C transceivers are functional. You are also to verify the RS
232C signal levels by an oscilloscope.
Task Two
You should establish a full-duplex serial communications channel to another Evaluation Board.
Use a cable furnished by your lab TA to connect your system to another one in the Lab. Don't
forget the common signal ground reference!
i. First, develop a C program that will either send, or receive a single character
to/from the other board. For the serial interface, use 8-bit characters with no
parity bit, and one Stop bit. The Baud rate value will be given in the Prelab
Assignment, or will be determined by your lab TA. Before any transmission would
take place, your program should read the contents of a memory location (specified
in the Prelab Assignment, or will be determined by your lab TA) to decide whether
data should be sent or received. The data to be sent (received) should be taken
from (stored at) another memory location given in the Prelab Assignment. The
pf2

Partial preview of the text

Download RS232C and SPI Serial Communications Interface Lab - Prof. Janos L. Grantner and more Lab Reports Microcomputers in PDF only on Docsity!

Laboratory Ten

Serial Communications Interface

Objectives:

i. To understand the RS232C asynchronous serial communications interface

ii. To use one of the SCI Modules of the 9S12DP512 microcontroller to send and receive messages over an asynchronous serial communications port

iii. To familiarize with the Serial Peripheral Interface (SPI) Module of the 9S12DP512 microcontroller

iv. To develop a C program that will act as a master/slave for transmitting/receiving data over a SPI interface

Task One

You should build a RS 232C compatible asynchronous communications interface on your breadboard.

Build a RS 232C compatible transmitter and a receiver circuit on your breadboard (use MC 1488 line driver and MC 1489 receiver devices, respectively, or compatibles). First, to verify your circuit, place a short-circuit between the RS 232C output and input terminals. Develop a program that will configure the associated Port S bits as input and output, respectively. Your program should then prove that your RS 232C transceivers are functional. You are also to verify the RS 232C signal levels by an oscilloscope.

Task Two

You should establish a full-duplex serial communications channel to another Evaluation Board. Use a cable furnished by your lab TA to connect your system to another one in the Lab. Don't forget the common signal ground reference!

i. First, develop a C program that will either send, or receive a single character to/from the other board. For the serial interface, use 8-bit characters with no parity bit, and one Stop bit. The Baud rate value will be given in the Prelab Assignment, or will be determined by your lab TA. Before any transmission would take place, your program should read the contents of a memory location (specified in the Prelab Assignment, or will be determined by your lab TA) to decide whether data should be sent or received. The data to be sent (received) should be taken from (stored at) another memory location given in the Prelab Assignment. The

program will then work with transmit and receive interrupts, respectively, to synchronize the data transfer between the two boards. The programs running on the two, interconnected Evaluation Boards should be able to exchange their unique single character messages. Verify the success of the data transfer by checking and printing out the contents of the send/receive data locations. In addition, use a logic analyzer with a probe hooked up to the TTL-level TXD (RXD) signal to record the sent (received) character and to verify the actual Baud rate.

ii. Now modify your program such that it will not check the contents of the designated memory location to decide the direction of the message transfer. Rather it will run in an infinite cycle and will simultaneously send and receive the single character messages. Again verify the success of the data transfers by making memory dumps.

Task Three

Repeat Task Two Part ii but now simultaneously send and receive messages made up of a string of up to 32 characters. Use the $00 (EOS) code for string terminator. Again, use memory dumps to verify the results of the transferred messages. You don’t need to use a logic analyzer to record the complete messages at this time.

Task Four

Develop a C program that will either send, or receive a single character to/from the other board using the designated SPI channel. For the SPI interface, use 8-bit characters. The Baud rate value will be given in the Prelab Assignment, or will be determined by your lab TA. Before any transmission would take place, your program should read the contents of a memory location (specified in the Prelab Assignment, or will be determined by your lab TA) to decide whether the controller should act as a master (transmit) or as a slave (receive). The initial configuration will be determined by the Lab TA. The data to be sent (received) should be taken from (stored at) another memory location given in the Prelab Assignment. The program will then work with send and receive interrupts, respectively, to synchronize the data transfer between the two boards. Your program should run in an infinite loop. Verify the success of the data transfer by checking and printing out the contents of the send/receive data locations. In addition, use a logic analyzer with a probe hooked up to the TTL-level MISO (MOSI) signal to record the sent (received) character and to verify the actual Baud rate.

Comment on your results. You are to turn in hard copies of the timing diagrams for the single character transmissions both for Tasks Two and Four, and the memory dumps on the results. In addition, turn in your schematic diagram complete with IC part and pin numbers and H connector pin numbers, as needed. The MC9S12DP512 programs should be documented by hard copies of your C source code and compiled list ( *.lst ) files.