Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.

Channels ▼

Embedded Systems

Designing a Parallel-to-Serial Port Adapter

The Design of a Parallel-toSerial Adapter Using the AT89C2051 Microcontroller

The heart of the adapter is the microcontroller AT89C2051. AT89C2051 is a Atmel 20-pin microcontroller with 2k bytes of programmable and erasable read only memory (PEROM) with 15 I/O lines including a full duplex serial port and 8-bit bi-directional port and is compatible with the MCS-51 instruction set. All the data transfer described below was done with the microcontroller being set to mode one (one start bit, 8 data bits, one stop bit) and baud rate given by the following equation:

Baud rate = ((2<sup>SMOD</sup>)*12*(106))/(32*12*(256-nu))

where nu is the number to be loaded in the timer 1 register (=CCh for 1200, EEh for 3600, F9h for 9600), SMOD = 1. The data transfer was carried out at various baud rates using 12MHz crystal oscillator used at the microcontroller end.

Parallel to Serial Port Communication

Parallel to serial port communication using same PC can be established as follows. Strobe, Busy, and Ack signals of the SPP are used for handshaking whereas RS232 serial port is used in software handshake mode. Listings 1 and 2 (at the of this article) present the assembly and C program used to test the adapter in parallel-to-serial data transmission mode. Figure 2 is the circuit diagram for this. Figure 3 is the timing diagram for parallel-to-serial data transfer using handshake signals. The timing cycles for parallel to serial data transfer are:

  1. The program on the PC first checks the Busy line. If Busy is low (i.e. microcontroller is ready to receive data), it writes data on the data register and sends Strobe signal (changes Strobe to low) and waits for Ack from the microcontroller.
  2. On receiving strobe signal, microcontroller deasserts Busy to high, reads data and sends Ack (sets Ack to high).
  3. As soon as PC receives Ack signal, it removes Strobe and removes data (writes 0xff on data lines since, microcontroller requires all the pins on which it is receiving data i.e. port 1 to be set to high in order for it to read data on the data lines) and waits for Busy to be asserted low by the controller.
  4. After receiving Strobe, microcontroller deasserts Ack to low and sends the byte to the PC over the serial port and deasserts Busy to low.
  5. Program reads the byte from the serial register and the next cycle begins.

The program was tested successfully with baud rates of 1200 and 3600.

[Click image to view at full size]
Figure 2: Circuit Diagram for Parallel Port to Serial Port Interface using AT89C2051 microcontroller

[Click image to view at full size]
Figure 3: Timing Diagram for Parallel-to-Serial Interface using the AT89C2051 microcontroller

Related Reading

More Insights

Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.