48
User’s Manual for 8251/8253 study card 1 8251 AND 8253 PROGRAMMABLE COMMUNICATION INTERFACE AND PROGRAMMABLE INTERVAL TIMER 1. INTRODUCTION Electro System Associates Private Limited (ESA) manufactures trainers for most of the popular microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of modules, which can be interfaced, to these trainers. These modules can be effectively used for teaching/training in the laboratories. The 8251 and 8253 study card incorporates Intel’s 8251 and 8253. The interface is designed to explain all the facilities available in 8251 and 8253. Functional description of 8251 and 8253, implementation of the circuit and some simple software are presented in this manual. 2. DESCRIPTION OF THE CIRCUIT: The study card provides 8251 as well as timer section. The interface has got 4 connectors. J3,J4 and P1 used for various trainer kits. J2 (10 pin FRC right angle male connector) is used for connecting RS232C cable to the COM port of the system. 10 RED LEDs are provided to indicate the important signals. 6.144MHz crystal is provided to drive 1.5 MHz clock. The following table describes the various hardware configurations for 8251 and 8253 using jumper settings. Jumper Position Description JP1 1-2 *2-3 GATE1 is connected externally. GATE1 is connected to VCC. JP2 1-2 *2-3 GATE2 is connected externally. GATE2 is connected to VCC. JP3 1-2 *2-3 CLK1 is derived externally. 1.5 Mhz clock is given to CLK1. JP4 1-2 *2-3 OUT1 is given to CLK2. CLK2 is derived externally. JP5 OPEN *CLOSED CLK0 is left unconnected. 1.5Mhz clock is given to CLK0. JP6 *OPEN CLOSED RxD and TxD are not shorted. RxD and TxD are shorted. JP7 *OPEN CLOSED CTS and RTS are not shorted. CTS and RTS are shorted. JP8 *OPEN CLOSED 8251 chip select derived from decoder. 8251 chip select derived externally.

8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

  • Upload
    buidiep

  • View
    249

  • Download
    2

Embed Size (px)

Citation preview

Page 1: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

1

8251 AND 8253

PROGRAMMABLE COMMUNICATION INTERFACE AND

PROGRAMMABLE INTERVAL TIMER

1. INTRODUCTION

Electro System Associates Private Limited (ESA) manufactures trainers for most of the popular

microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of modules, which

can be interfaced, to these trainers. These modules can be effectively used for teaching/training in the

laboratories.

The 8251 and 8253 study card incorporates Intel’s 8251 and 8253. The interface is designed to explain all the

facilities available in 8251 and 8253.

Functional description of 8251 and 8253, implementation of the circuit and some simple software are

presented in this manual.

2. DESCRIPTION OF THE CIRCUIT:

The study card provides 8251 as well as timer section. The interface has got 4 connectors.

J3,J4 and P1 used for various trainer kits. J2 (10 pin FRC right angle male connector) is used for connecting

RS232C cable to the COM port of the system. 10 RED LEDs are provided to indicate the important signals.

6.144MHz crystal is provided to drive 1.5 MHz clock.

The following table describes the various hardware configurations for 8251 and 8253 using jumper

settings.

Jumper Position Description

JP1 1-2

*2-3

GATE1 is connected externally.

GATE1 is connected to VCC.

JP2 1-2

*2-3

GATE2 is connected externally.

GATE2 is connected to VCC.

JP3 1-2

*2-3

CLK1 is derived externally.

1.5 Mhz clock is given to CLK1.

JP4 1-2

*2-3

OUT1 is given to CLK2.

CLK2 is derived externally.

JP5 OPEN

*CLOSED

CLK0 is left unconnected.

1.5Mhz clock is given to CLK0.

JP6 *OPEN

CLOSED

RxD and TxD are not shorted.

RxD and TxD are shorted.

JP7 *OPEN

CLOSED

CTS and RTS are not shorted.

CTS and RTS are shorted.

JP8 *OPEN

CLOSED

8251 chip select derived from decoder.

8251 chip select derived externally.

Page 2: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

2

3.0 INSTALLATION:

Please refer the below table for connection procedure for various trainer

kits. Sl. No Model No. Studycard

Adapter

Connection Procedure

1 MPS 85-3 No Adapter Connect 26 pin FRC cables between J3, J4 of study card with

J3 ,J4 of the trainer kit respectively.

2 ESA 85-2 No Adapter Connect 50 pin FRC cable between P1 of study card with P1

of the trainer kit .

3 ESA 86/88-

2

Study card adapter

for ESA 86-2/3

trainer

Connect 50 pin FRC cables between J1, J2 of the adapter

with J1,J2 of the trainer kit.

Connect 26 pin FRC cables between J3,J4 of the adapter with

J3,J4 of the study card respectively.

4 ESA 86/88-

3

Study card adapter

for ESA 86-2/3

trainer

Connect 50 pin FRC cables between J1, J2 of the adapter

with J1,J2 of the trainer kit.

Connect 26 pin FRC cables between J3,J4 of the adapter with

J3,J4 of the study card respectively.

5 ESA 86E No Adapter Connect 26 pin FRC cables between J3, J4 of study card with

J6 ,J7 of the trainer kit respectively.

6 ESA 31 Study Card adapter

ESA 31/51 Trainer

Connect 50 pin FRC cable between J1 of adapter with J5 of

the trainer kit.

Connect 26 pin FRC cables between J3,J4 of adapter with

J3,J4 of the study card respectively.

7 ESA 51 Study Card adapter

ESA 31/51 Trainer

Connect 50 pin FRC cable between J1 of adapter with J1 of

the trainer kit.

Connect 26 pin FRC cables between J3,J4 of adapter with

J3,J4 of the study card respectively.

8 ESA 51E ESA 51E Study

card adapter.

Connect 50 pin FRC cable between P3 of adapter with P1 of

study card.

Connect 26 pin FRC cables between J3 ,J4 of adapter with

J4,J6 of the trainer kit respectively.

The 8251A programmable communication interface

The 8251A is a programmable chip designed for synchronous and a synchronous serial data communication,

packaged in a 28 – pin DIP. The 8251A is the enhanced version of its predecessor, the 8251, and it is

compatible with the 8251. Figure1 shows the block diagram of the 8251A. It includes 5 sections: Read/Write

Control Logic, Transmitter, Receiver, Data Bus Buffer, and Modem Control.

The control logic interfaces the chip with the MPU, determines the function of the chip according to the

control word in its register (to be explained below), and monitors the data flow. The transmitter section

converts a parallel word received from the MPU into serial bits and transmits them over the TxD line to a

peripheral. The receiver section receives serial bits from a peripheral, converts them into a parallel word, and

transfers it to MPU. The 8251A is a complex device capable of performing various functions. For the sake of

clarity, this chapter focuses only on the asynchronous mode of serial I/O, and excludes any discussion of the

synchronous mode and the modem control. The asynchronous mode is often used for the data communication

between the MPU and serial peripherals such as terminals and floppy disks.

Page 3: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

3

Figure 2 shows an expanded version of the 8251A block diagram. The block diagram shows all the elements

of a programmable chip; It includes the interfacing signals, the control register, and the status register. The

functions of the various blocks are described below.

READ/WRITE CONTROL LOGIC AND REGISTERS

This section includes R/W control logic, six input signals, control logic and three buffer registers: data

register, control register, and status register. The input signals to the control logic are as follows.

Input signals

CS*-chip select: When this signal goes low, the 8251A is selected by the MPU for communication.

This is usually connected to a decoded address bus.

C/D*-control/data: when this signal is high, the control register or the status register is addressed.

The control register and the status register are differentiated by WR* and RD* signals, respectively.

FIGURE 2: The 8251A: Expanded Block Diagram of Control Logic and Registers

WR*-Write: When this signal goes low, the MPU either writes in the control register or sends

output to the data buffer. This is connected to IOW* or MEMW*.

RD*-Read: When this signal goes low, the MPU either reads a status register or accepts (input) data

from the data buffer. This is connected to either IOR* or MEMR*

RESET-Reset: A high on this input resets the 8251A and forces it into the idle mode.

CLK-Clock: This is the clock input, usually connected to the system clock. This clock does not

control either the transmission or the reception rate. The clock is necessary for communication with

the microprocessor.

Page 4: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

4

Control Register This 16-bit register for a control word consists of two independent bytes: the first byte is

called the mode instruction (word) and the second byte is called command instruction (word). This register

can be accessed as an output port when the C/D* pin is high.

Status Register: This input register checks the ready status of a peripheral. This register is addressed as an

input port when the C/D* pin is high, it has the same port address as the control register.

Data Buffer :This bi-directional register can be addressed as an input port and output port when the C/D* pin

is low. Table 1 summarizes all the interfacing and control signals.

CS* C/D* RD* WR* Function

0 1 1 0 MPU writes instructions in the control register.

0 1 0 1 MPU reads status from the status register

0 0 1 0 MPU outputs data to the Data Buffer

0 0 0 0 MPU accepts data from the Data Buffer

1 X X X USART is not selected.

TRANSMITTER SECTION

The transmitter accepts parallel data from the MPU and converts them into serial data . It has two registers: a

buffer register to hold eight bits and an output register to convert eight bits into steam of serial bits (figure 3)

.the MPU writes a byte in the buffer register . whenever the output register is empty, the contents of the buffer

register are transferred to the output register. This section transmits data on TxD pin with the appropriate

framing bits (START and STOP) . Three output signals and one input signal are associated with the

transmitter section.

TxD-Transmit Data: Serial bits are transmitted on this line.

TxC*-Transmitter Clock: This input signal controls the rate at which the bits are transmitted by the

USART.The clock frequency can be 1,16 or 64 times the baud.

TxRDY-transmitter Ready: This is the output signal. When it is high, it indicates the buffer register is empty

and USART is ready to accept a byte .It can be used either to interrupt the MPU or to indicate the status. This

signal is reset when a data byte is loaded into the buffer.

TxE-Transmitter Empty: This is an output signal. Logic 1 on this indicates the output register is empty. This

signal is reset when a byte is transferred from the buffer to the output register.

Page 5: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

5

FIGURE 3

The 8251A: Expanded Block Diagram of Transmitter and Receiver Section

RECEIVER SECTION

The receiver accept serial data on the RxD line from a peripheral and converts them into parallel data . The

section has two registers: the receiver input register and the buffer register (figure 3).

When the RxD line goes low, the control logic assumes it is a START bit , waits for half a bit time , and

sample the line again. If the line is still low , the input register accepts the following bits, form a character ,and

load it into the buffer register. Subsequently, the parallel byte is transferred to the MPU when requested. In

the asynchronous mode , two input signal and one output signal are necessary ,as described below.

RxD-Receive Data: Bits are received serially on this line and converted into a parallel byte in the receiver

input register.

RxC-Receiver clock: This is a clock signal that controls the rate at which bits are received by the USART. In

the asynchronous mode, the clock can be set to 1,16 or 64 times the baud.

RxRDY-Receiver Ready: This is an output signal. It goes high when the USART has a character in the

buffer register and is ready to transfer into the MPU. This line can be used either to indicate the status or to

interrupt the MPU

Page 6: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

6

INITIALIZING THE 8251A

To implement serial communication, the MPU must inform the 8251A of all details such as mode, baud, stop

bits, parity, etc. Therefore, prior to data transfer, a set of control words must be loaded into the 8 -bit control

register of the 8251A. In addition, the MPU must check the readiness of the peripheral by reading the status

register. The control words are divided into two formats: mode words and command words. The mode word

specifies the general characteristics of operation ( such as baud , parity, number of stop bits),the command

word enable data transmission and /or reception, and the status word provides the information concerning

register status and transmission errors. Figure 4 shows the definition of these words.

To initialize the 8251A in the asynchronous mode, a certain sequence of control words must be followed.

After a Reset operation (system Reset or through instruction), a mode word must be written in the control

register followed by a command word. Any control word written in the control register immediately after a

word will be interpreted as a command word ,that means a command word can be changed any time during the

operation. However, the 8251A should be reset prior to writing a new mode word, and it can be reset by using

the Internal Reset bit (D6) in the command word.

Page 7: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

7

Note: * indicates active low signal

FIGURE 4

Mode Word Format (A),Command Word Format (B) and Status word Format (C)

Page 8: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

8

Page 9: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

9

Page 10: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

10

FIGURE 1

The 8251 A: Block Diagram, Pin Configuration and Description.

Page 11: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

11

8253 / 8253-5

PROGRAMMABLE INTERVAL TIMER

MCS-85TM

Compatible 8253-5

3 Independent 16-Bit Counter

DC to 2 MHz

Programmable Counter Modes

Count Binary or BCD

Single +5V Supply

24-Pin dual In –line Package

The Intel R 8253 is a programmable counter/timer chip designed for use as an Intel microcomputer peripheral.

It uses nMOS technology with a single +5V supply and is packaged in a 24 pin plastic DIP.

It is organized as 3 independent 16 bit counters, each with a count rate of up to 2 Mhz. All modes of operation

are software programmable.

Page 12: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

12

FUNCTIONAL DESCRIPTION

General

The 8253 is a programmable interval timer/counter specifically designed for use with the IntelTM

microcomputer systems. Its function is that of a general purpose ,multi-timing element that can be treated as

an array of I/O ports in the system software.

The 8253 solves one of the most common problems in the microcomputer system , the generation of accurate

time delays under software control. Instead of setting up timing loops in system software ,the programmer

configures the 8253 to match his requirements, initialize one of the counter of 8253 with the desired quantity

, then upon command the 8253 will count out the delay and interrupt the CPU when it has completed its tasks

it is easy to easy to see that the software overhead is minimal and that multiple delays can easily be maintained

by assignment of priority levels.

Other counter / timer functions that are non delay in nature but also common to most microcomputers can be

implemented with the 8253.

Programmable Rate Generator

Event Counter

Binary rate multiplier

Real Time Clock

Digital One -shot

Complex Motor controller

Data Bus Buffer

This 3-state, bi-directional, 8-bit buffer is used to interface the 8253 to the system data bus. Data is

transmitted or received by the buffer upon execution of IN put or OUT put CPU instructions. The Data Bus

Buffer has three basic functions

1. Programming the MODES of the 8253.

2. Loading the count registers.

3. Reading the count values.

Read/Write Logic

The Read/Write Logic accepts inputs from the system bus and in turn generates control

signals for overall device operation. It is enabled or disabled by CS so that no operation can

occur to change the function unless the device has been selected by the system logic.

RD*(Read)

A “low” on this input informs the 8253 that the CPU is inputting the data in the form of a counter value.

WR*(Write)

A “low” on this input informs the 8253 that the CPU is outputting the data in the form of mode information or

loading counters

Page 13: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

13

A0, A1

These inputs are normally connected to the address bus. Their function is to select one of the three counters to

be operated on and to address the control word register for mode selection.

CS*(Chip Select)

A “low” on this input informs the 8253. No reading or writing will occur unless the device is selected. The

CS*input has no effect upon the actual operation of the counters.

CS* RD* WR* A1 A0

0 1 0 0 0 Load Counter No.0

0 1 0 0 1 Load Counter No.1

0 1 0 1 0 Load Counter No.2

0 1 0 1 1 Write Mode Word

0 0 1 0 0 Read Counter No.0

0 0 1 0 1 Read Counter No.1

0 0 1 1 0 Read Counter No.2

0 0 1 1 1 No-operation 3 state

1 X X X X Disable 3 state

0 1 1 X X No-operation 3 state

Page 14: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

14

Control Word Register

The control word register is selected when A0, A1 are 11. It then accepts information from the data bus buffer

and stores it in a register. The information stored in this register controls the operational MODE of each

counter, selection of binary or BCD counting and the loading of each count register.

The Control Word Register can only be written into; no read operation of its contents is available.

Counter #0, counter#1, counter#2

These three function blacks are identical in operation so only a single counter will be described. Each

Counter consists of a single ,16, pre-settable , DOWN counter. The counter can operate in either binary or

BCD and its input, gate and output are configured by the selection of MODES stored in the Control Word

Register.

The counters are fully independent and each can have separate Mode configuration and counting operation,

binary or BCD. Also ,there are special features in the control word that handle the loading of the count value

so that software overhead can be minimized for these functions .

The reading of the contents of each counter is available to the programmer with simple READ operations for

event counting applications and special commands and logic are included in the 8253 so that the contents of

each counter can read “on the fly” without having to inhibit the clock input.

8253 SYSTEM INTERFACE

The 8253 is a component of the Intel TM

microcomputer systems and interfaces in the same manner as all

other peripherals of the family. It is treated by the system software as an array of peripheral I/O ports ; three

are counters and the fourth is a control register for MODE programming.

Basically, the select inputs A0, A1 connect to the A0,A1 address bus signals of the CPU. The CS* can be

derived directly from the address bus using a linear select method. Or it can be connected to the output of a

decoder, such as an Intel 8205 for larger systems.

Figure 4: Block Diagram Showing Control Word Register and Counter Functions.

Page 15: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

15

OPERATIONAL DESCRIPTION

General

The complete functional definition of the 8253 is programmed by the systems software. A set of control words

must be sent out by the CPU to initialize each counter of the 8253 with the desired MODE and quantity

information. Prior to initialize, the MODE, count, and output of all counters is undefined.

These control words program the MODE, Loading sequence and selection of binary or BCD counting.

Once programmed, the 8253 is ready to perform whatever timing tasks it is assigned to accomplish.

The actual counting operation of each counter is completely independent and additional logic is provided on-

chip so that the usual problems associated with efficient monitoring and management of external,

asynchronous events or rates to the microcomputer system have been eliminated.

Programming the 8253

All of the MODES for each counter are programmed by the system software by simple I/O operations.

Each counter of the 8253 is individually programmed by writing a control word in to the control word

register. (A0 A1=11).

Control Word Format

D7 D6 D5 D4 D3 D2 D1 D0

SC1 SC0 RL1 RL0 M2 M1 M0 BCD

Definition of Control

SC –Select Counter:

SC1 SC0

0 0 Select Counter 0

0 1 Select Counter 1

1 0 Select Counter 2

1 1 Illegal

RL-Read/Load:

RL1 RL0

0 0 Counter latching operation (see READ/WRITE procedure section)

1 0 Read/Load most significant byte only.

0 1 Read/Load least significant byte only.

1 1 Read/Load least significant byte first, then most significant byte.

M _ MODE M2 M1 M0

0 0 0 Mode 0

0 0 1 Mode 1

X 1 0 Mode 2

X 1 1 Mode 3

1 0 0 Mode 4

1 0 1 Mode 5

Page 16: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

16

BCD:

0 Binary Counter 16 bits

1 Binary Coded Decimal (BCD) Counter ( 4 Decades)

Counter Loading

The count register is not loaded until the count value is written (one or two bytes, depending on the mode

selected by the RL bits), followed by a rising edge and a falling edge of the clock. Any read of the counter

prior to that falling clock edge may yield invalid data.

Mode Definition

MODE 0: Interrupt on Terminal count. The output will be initially low after the mode set operation. After

the count is loaded into the selected count register, the output will remain low and the counter will count.

When the terminal count is reached the output will go high and remain high until the selected count register is

reloaded with the mode or a new count is loaded. The counter continues to decrement after terminal count has

been reached.

Rewriting a counter register during counting result in the following

1. Write 1st byte stops the current counting.

2. Write 2nd

byte start the new count.

MODE 1: Programmable One-Shot. The output will go low on the count following the rising edge of the

gate input.

The output will go high on the terminal count. If a new count value is loaded while the output is low it will not

affect the duration of the one –shot pulse until the succeeding trigger. The current count can be read at any

time without affecting the one-shot pulse.

The one–shot is retriggerable, hence the output will remain low for the full count after any rising edge of the

gate input.

MODE 2: Rate Generator. Divide by N counter. The output will be low for one period of the input clock.

The period from the output pulse to the next equals the number of input counts in the count register. If the

count register is reloaded between output pulses the present period will not be affected, but the subsequent

period will reflect the new value.

The gate input, when low, will force the output high. When the gate input goes high, the counter will start

from the initial count. Thus the gate input can be used to synchronize the counter

When this mode is set, the output will remain high until after the counter register is loaded. The output then

can also synchronized by software.

Mode 3: Square Wave Rate Generator. Similar to MODE 2 except that the output will remain high until

one half the count has been completed (for even numbers) and go low for the other half of the count. This is

accomplished by decrementing the counter by two on the falling edge of each clock pulse. When the counter

reaches terminal count , the state of the output is changed and the counter is reloaded with the full count and

the whole process is repeated .

If the count is odd and the output is high, the first clock pulse (after the count is loaded) decrements the count

by 1. Subsequent clock pulses decrement the clock by 2. After timeout, the output goes low and the full count

Page 17: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

17

is reloaded. The first clock pulse (following the reload) decrements the counter by 3. Subsequent clock pulses

decrement the count by 2 until the timeout. Then the whole process is repeated in this way, if the count is odd,

the output will be high for (N+1)/2 counts and low for (N-1)/2 counts.

MODE 4:Software Triggered Strobe. After the mode is set , the output will be high. When the count is

loaded. The counter will begin counting . On terminal count, the output will go low for one input clock period,

and then will go high again.

If the count register is reloaded between output pulses, the present period will not be affected, but the

subsequent period will reflect the new value. The count will be inhibited while the gate input is low.

Reloading the counter register will restart counting beginning with new number.

MODE 5: Hardware Triggered strobe. The counter will start counting after the rising edge of the trigger

input and will go low for one clock period when the terminal count is reached. The counter is retriggerable.

The output will not go low until the full count after the rising edge of any trigger

Modes/Signa

l Status

Low Or going low Rising High

0 Disables counting Enables counting

1 1.Initiates counting

2.Resets output after

next clock

2 1.Disables

counting

2.Sets output

immediately high

1.Reloads counter

2.Initiates counting

Enables counting

3 1.Disables

counting

2.Sets output

immediately high

Initiates counting Enables counting

4 Disables counting Enables counting

5 Initiates counting

Figure 6. Gate Pin Operations Summary.

Page 18: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

18

8253 READ/WRITE PROCEDURE

Page 19: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

19

Write Operations

The system software must program each counter of the 8253 with the mode and quantity

desired. The programmer must write out to the 8253 a MODE control word and the

programmed number of count register bytes (1 or 2) prior to actually using the selected

counter.

The actual order of the programming is quite flexible. Writing out of the MODE control

word can be in any sequence of counter section, e.g., counter#2 last. Each counter’s MODE

control word register has a separate address so that its loading is completely sequence

independent. (SC0, SC1).

The loading of the count register with the actual count value, however must be done in

exactly the sequence programmed in the MODE control word ( RL0,RL1). This loading of

the counter’s count register is still sequence independent like the MODE control word

loading, but when a selected count register is to be loaded it must be loaded with the

number of bytes programmed in the MODE control word ( RL0-RL1). The one or two

bytes to be loaded in the count register do not have to follow the associated MODE control

word. They can be programmed at any time following the MODE control word loading as

long as the correct number of bytes is loaded in order.

All counters are down counters. Thus the value loaded in to the count register will actually

be decremented. Loading all zeroes in to a count register will result in the maximum count (

2 16

for binary or 104

for BCD). In MODE 0 the new count will not restart until the load has

been completed. It will accept one of two bytes depending on how the MODE control

words ( RL0-RL1) are programmed. Then proceed with the restart operation.

MODE Control Word Counter n

LSB Count Register byte Counter n

MSB Count Register byte Counter n

Note: Format shown is a simple example of loading the 8253 and does not reply imply that

it is the only format that can be used.

A1 A0

No.1 MODE control Word

Counter 0

1 1

Page 20: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

20

No.2 MODE control Word

Counter 1

1 1

No.3 MODE control Word

Counter 2

1 1

No.4 LSB Count Register Byte Counter

1

0 1

No.5 MSB Count Register Byte Counter

1

0 1

No.6 LSB Count Register Byte Counter

2

1 0

No.7 MSB Count Register Byte Counter

2

1 0

No.8 LSB Count Register Byte Counter

0

0 0

No.9 MSB Count Register Byte Counter

0

0 0

Note: The exclusive addresses of each counter’s count register make the task of programming the 8253 a very

simple matter, and maximum effective use of the device will result if this feature is fully utilized.

Figure 9. Alternating Programming Formats.

Read operations

In most counter applications it becomes necessary to read the value of the count in progress

and make a computational decision based on this quantity. Event counters are probably the

most common application that uses this function. The 8253 contains logic that will allow

the programmer to easily read the contents of any of three counters without disturbing the

actual count in progress.

There are two methods that the programmer can use to read the value of the counters. The

first method involves the use of simple I/O read operations of the selected counter. By

controlling the A0, A1 inputs to the 8253 the programmer can select the counter to be read (

remember that no read operation of the mode register is allowed. A0, A1-A11). The only

requirement with this method is that in order to assure a stable count reading the actual

operation of the selected counter must be inhibited either by controlling the Gate input or

by external logic that inhibits the clock input. The contents of the counter selected will be

available as follows.

First I/O Read contains the least significant byte (LSB).. Second I/O Read contains the most

significant byte (MSB).

Page 21: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

21

Due to the internal logic of the 8253 it is absolutely necessary to complete the entire

reading procedure. If two bytes are programmed to be read then two bytes must be read

before any loading WR commands can be sent to the same counter.

Read Operation Chart

A1 A0 RD

0 0 0 Read Counter No.0

0 1 0 Read Counter No.1

1 0 0 Read Counter No.2

1 1 0 Illegal

Reading While Counting

The order for the programmer to read the contents of any counter without effecting or

disturbing the counting operation the 8253 has special internal logic that can be accessed

using simple WR commands to the MODE register. Basically in the programmer wishes to

read the contents of a selected counter “ on the fly” he loads the MODE register with a

special code which lathes

MODE Register for Latching count

A0,A1=11

D7 D6 D5 D4 D3 D2 D1 D0

SC1 SC0 0 0 X X X X

SC1,SC0-Specify counter to be latched.

D5,D4-D0 designates counter latching operation.

X-don’t care

The same limitation applies to this mode of reading the counter as the previous method.

That is, it is mandatory to complete the entire read operation as programmed. This

command has no effect on the counter’s mode.

Page 22: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

22

4.0 Demonstration programs for 8085 Series kits.

Sample programs for MPS 85-3 and ESA 85-2 trainer

1. Program to display "WELCOME TO ESA 8251 STUDY CARD" for 9600

baud by initializing 8251.Execute the program from 8000H.

CMD53 EQU 83H

CMD51 EQU 91H

DAT51 EQU 90H

ADDRESS OPCODE LABLE MNOMONIC COMMENTS

ORG 8000H

8000 11 0A 00 LXI D,000AH ;TIMER 0 for

;9600 BAUD

8003 3E 36 MVI A,36H ;TIMER 0 IN

;MODE 3

8005 D3 83 OUT CMD53

8007 7B MOV A,E ;LOAD LSB VALUE

8008 D3 80 OUT 80H

800A 7A MOV A,D ;LOAD MSB VALUE

800B D3 80 OUT 80H

800D AF XRA A ;DUMMY MODE

800E D3 91 OUT CMD51 ;WRITE DUMMY

;word

8010 D3 91 OUT CMD51 ;IN MODE reg

8012 D3 91 OUT CMD51

8014 D3 91 OUT CMD51

8016 3E 40 MVI A,40H ;RESET 8251

8118 D3 91 OUT CMD51

801A 3E CE MVI A,0CEH ;SET 8251 FOR

801C D3 91 OUT CMD51 ;ASYNCHRONOUS 16

;16X baud.

;2 STOP BITS,8

;data bits,

;No parity

801E 3E 27 MVI A,27H ;WRITE COMMAND

;Word

8020 D3 91 OUT CMD51

8022 21 00 90 LXI H,9000H ;MEMORY TO STORE

;the character

8025 06 33 MVI B,33H ;CHARACTER

8027 DB 91 STATUS: IN CMD51 ;GET USART

;status

8029 E6 81 ANI 81H ;RECEIVER READY

802B FE 81 CPI 81K ;NO,WAIT

802D C2 27 80 JNZ STATUS ;GET CHARACTER

;FROM USART

8030 7E MOV A,M

Page 23: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

23

8031 D3 90 OUT DAT51

8033 23 INX H

8034 05 DCR B

8035 C2 27 80 JNZ STATUS

9000 0A 0A 0A 0A ORG 9000H

9004 0A 0A 0A 20 TABLE: WELCOME TO ESA

9008 20 20 20 20 8251 STUDY CARD

900C 20 20 20 20

9010 20 20 20 57

9014 45 4C 43 4F

9018 4D 45 20 54

901C 4F 20 45 53

9020 41 20 38 32

9024 35 31 20 53

9028 54 55 54 59

902C 20 43 41 52

9030 44 2E 0D OA

**********************************************************************************

Sample programs for MPS 85-3 and ESA 85-2 trainer

2.Program to receive characters from the USART and display it on

console as well as stored it in memory from 8500H.The program is

in a continuous loop

Press ESC to come out of the loop.

CMD53 EQU 83H

CMD51 EQU 91H

DAT51 EQU 90H

ADDRESS OPCODE LABLE MNEMONIC COMMENTS

ORG 8000H

8000 11 0A 00 LXI D,000AH ;TIMER 0 for

;9600 BAUD

8003 3E 36 MVI A,36H ;TIMER0 IN

;MODE 3

8005 D3 83 OUT CMD53

8007 7B MOV A,E ;LOAD LSB VALUE

8008 D3 80 OUT 80H

800A 7A MOV A,D ;LOAD MSB VALUE

800B D3 80 OUT 80H

800D AF XRA A ;DUMMY MODE

800E D3 91 OUT CMD51 ;WRITE DUMMY

;WORD

8010 D3 91 OUT CMD51 ;IN MODE

;REGISTER

8012 D3 91 OUT CMD51

8014 D3 91 OUT CMD51

Page 24: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

24

8016 3E 40 MVI A,40H ;RESET 8251

8018 D3 91 OUT CMD51

801A 3E CE MVI A,0CEH ;SET 8251 FOR

801C D3 91 OUT CMD51 ;ASYNCHRONOUS

;16XBAUD,

;2 STOP BITS,8

;DATA

;BITS,NO PARITY

801E 3E 27 MVI A,27H ;WRITE COMMAND

;WORD

8020 D3 91 OUT CMD51

8022 21 00 85 LXI H,8500H ;MEMORY TO STORE

;THE

8025 CD 37 80 BACK: CALL GETCH ;CHARACTER TO

;MEMORY

8028 79 MOV A,C

8029 FE 1B CPI 27

802B CA 36 80 JZ DOWN

802E CD 42 60 CALL SOUTPT

8031 71 MOV M,C

8032 23 INX H

8C33 C3 25 80 JMP BACK

8036 EF DOWN: RST 5

8037 DB 91 GETCH: IN CMD51 ;GET USART

;STATUS

8039 E6 02 ANI 02H ;RECEIVER READY

803B CA 37 80 JZ GETCH ;NO,WAIT

803E DB 90 IN DAT51 ;GET CHARACTER

8040 4F MOV C,A ;FROM USART

8041 C9 RET

8042 DB 91 SOUTPT: IN CMD51

8044 E6 81 ANI 81H

8046 FE 81 CPI 81H

8048 C2 42 80 JNZ SOUTPT

804B 79 MOV A,C

804C D3 90 OUT DAT51

804E C9 RET

****************************************************************

Sample programs for MPS 85-3 and ESA 85-2 trainer

3. Initialize Timer 1 and display the count on Data field of the

trainer display. Execute the program from 8000H.The program is in

a continuous loop, press RESET key to come out of the loop.

CMD53 EQU 83H

CMD51 EQU 91H

Page 25: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

25

DAT51 EQU 90H

ADDRESS OPCODE LABLE MNEMONIC COMMENTS

ORG 8000H

8000 21 FF FF LX1 H,0FFFFH ;INITIALISE

;TIMER 1

8003 3E 76 MVI A,76H ;FOR MODE 3

8005 D3 83 OUT CMD53

8007 7D MOV A,L ;LSB OF TIMER 1

8008 D3 81 OUT 81H

800A 7C MOV A,H ;MSB OF TIMER 2

800B D3 81 OUT 81H

800D 3E 96 MVI A,96H ;LODE MODE WORD

800F D3 83 OUT CMD53

8011 3E FF MVI A,0FFH

8013 D3 82 ODT: OUT 82H

8015 3E 86 MVI A,86H ;LATCH COMMAND

;WORD

8017 D3 83 OUT CMD53

8019 DB 82 IN 82H

801B 32 Fl 8F STA 8FF1H

801E FE 80 CPI 80H

8020 CA 3F 80 JZ NDT

8023 06 00 MVI B,00H

8025 CD 4C 04 CALL 044C

8028 CD 2E 80 CALL DLY

802B C3 15 80 JMP ODT+2

802E 16 FF DLY: MVI D,0FFH

8030 1E 33 LP1: MVI E,33H

8032 1D LP: DCR E

8033 00 NOP

8034 00 NOP

8035 00 NOP

8036 00 NOP

8037 C2 32 80 JNZ LP

803A 15 DCR D

803B C2 30 80 JNZ LP1

803E C9 RET

803F 3E 70 NDT: MVI A,70H

8041 C3 13 80 JMP ODT

Sample programs for MPS 85-3 and ESA 85-2 trainer

4. Program to display "DEMO PROGRAM FOR AYSNCHRONOUS COMMUNICATION

IN INTERRUPT MODE" by using interrupt driven. Execute the program

from 8000H.

ADDRESS OPCODE LABLE MNOMONIC COMMENTS

ORG 8000H

8000 11 0A 00 LXI D,000AH ;TIMER 0 for

;9600 baud

8003 3E 36 MVI A,36H ;TIMER 0 IN

Page 26: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

26

;MODE 3.

8005 D3 83 OUT CMD53

8007 7B MOV A,E ;LOAD LSB VALUE

8008 D3 80 OUT 80H

800A 7A MOV A,D ;LOAD MSB VALUE

800B D3 80 OUT 80H

800D AF XRA A ;DUMMY MODE

800E D3 91 OUT CMD51 ;WRITE DUMMY WORD

8010 D3 91 OUT CMD51 ;IN MODE REGISTER

8012 D3 91 OUT CMD51

8014 D3 91 OUT CMD51

8016 3E 40 MVI A,40H ;RESET 8251

8018 D3 91 OUT CMD51

801A 3E CE MVI A,0CEH ;SET 8251 FOR

801C D3 91 OUT CMD51 ;ASYNCHRONOUS

;16XBAUD,

;2 STOP BITS,8

;DATA BITS

;NO PARITY

801E 3E 27 MVI A,27H ;WRITE COMMAND

;WORD

8020 D3 91 OUT CMD51

8022 21 00 90 LXI H,9000H ;MEMORY TO STORE

;THE

8025 06 45 MVI B,45H ;CHARACTER

8027 3E 0E MVI A,0EH ;ENABLE RST 5.5

8029 30 SIM

802A FB EI

802B 78 LOOP: MOV A,B

802C F6 00 ORI 0

802E C2 2B 80 JNZ LOOP

8031 EF RST 5

8032 F5 STATUS: PUSH PSW

8033 7E MOV A,M

8034 D3 90 OUT DAT51

8036 23 INX H

8037 05 DCR B

8038 F1 POP PSW

8039 FB EI

803A C9 RET

9000 0A 0A 20 20 20 TABLE:ORG 9000H

9005 44 45 4D 4F 20 DEMO PROGRAM FOR

900A 50 52 4F 47 52 ASYNCHRONOUS

900F 41 4D 20 46 4F COMMUNICATION IN

9014 52 20 41 53 59 INTERUPT MODE

9019 4E 43 48 52 4F

901E 4E 4F 55 53 20

9023 43 4F 4D 4D 55

9028 4E 49 43 41 54

902D 49 4F 4E 20 49

9032 4E 20 49 4E 54

9037 45 52 52 55 50

Page 27: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

27

903C 54 20 4D 4F 44

9041 45 2E 0D 0A 00

ORG 8FB3H

8FB3 C3 32 80 JMP STATUS

****************************************************************

5.0 Demonstration programs for 8051 Series kits.

EXAMPLE PROGRAMS FOR ESA 31/51 TRAINERS

1.Program to display "WELCOME TO ESA 8251 STUDY CARD" for 9600

baud by initializing 8251. Execute the Program at 8000H.

CONTROL REGISTER = F183

DATA PORT = F190

COMMAND PORT = F191

ADDRESS OPCODE LABLE MNEMONIC COMMENTS

ORG 8000H

8000 74 36 MOV A,#36H ;Timer0 for

;9600 baud

8002 90 F1 83 MOV DPTR,#0F183H ;in mode3

8005 F0 MOVX @DPTR,A

8006 90 F1 80 MOV DPTR,#0F180H

8009 74 0A MOV A,0AH

800B F0 MOVX @DPTR,A

800C 74 00 MOV A,#00H

800E F0 MOVX @DPTR,A

800F 90 F1 91 MOV DPTR,#0F191H ;USART

8012 F0 MOVX @DPTR,A

8013 F0 MOVX @DPTR,A

8014 F0 MOVX @DPTR,A

8015 F0 MOVX @DPTR,A

8016 74 40 MOV A,#40H ;Reset 8251

8018 F0 MOVX @DPTR,A

8019 74 CE MOV A,#0CEH

801B F0 MOVX @DPTR,A

801C 74 01 MOV A,#01H

801E F0 MOVX @DPTR,A

801F 90 90 00 MOV DPTR,#9000H

8022 79 00 MOV R1,#00H

8024 C0 83 STATUS: PUSH DPH ;Get USART

;Status

8026 C0 82 PUSH DPL

8028 90 F1 91 MOV DPTR,#0F191H

802B E0 MOVX A,@DPTR

802C 54 81 ANL A,#81H

802E D0 82 POP DPL

8030 D0 83 POP DPH

8032 B4 01 EF CJNE A,#01H,STATUS

8035 74 00 MOV A,#00H

8037 93 MOVC A,@A+DPTR

8038 B4 00 03 CJNE A,#00H,CONT

803B 02 00 00 LJMP 0

Page 28: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

28

803E C0 83 CONT: PUSH DPH

8040 C0 82 PUSH DPL

8042 90 F1 90 MOV DPTR,#0F190H

8045 F0 MOVX @DPTR,A

8046 D0 82 POP DPL

8048 D0 83 POP DPH

804A A3 INC DPTR

804B 80 D7 SJMP STATUS

ORG 9000H

9000 0A 0A 0A 0A 0A TABLE: DB 0AH,0AH,0AH,0AH,0AH

9005 0A 0A 0A DB 0AH,0AH,0AH

9008 20 20 20 20 20 DB 20H,20H,20H,20H,20H

900D 20 20 20 DB 20H,20H,20H

9010 57 45 4C 43 4F DB ‘WELCOME TO ESA STUDY

CARD’,0DH,00H’

9015 4D 45 20 54 4F

9D1A 20 45 53 41 20

901F 53 54 55 44 59

9024 20 43 41 52 44

9029 0D 00

EXAMPLE PROGRAMS FOR ESA 31/51 TRAINERS

2.Program to receive characters from the USART and display it on

Console as well as stored it in memory from 9000h. The program is

in a continuous loop, press ESC to come out from the loop. Execute

the Program at 8000H.

ADDRESS OPCODE LABLE MNEMONIC COMMENTS

ORG 8000H

8000 74 36 MOV A,#36H

8002 90 Fl 83 MOV DPTR,#0F183H ;TIMER 0 CMD

8005 F0 MOVX @DPTR,A

B006 90 Fl 80 MOV DPTR,#0F180H

8009 74 0A MOV A,#0AH ;TIMER 0DATA

800B F0 MOVX @DPTR,A

800C 74 00 MOV A,#00H

800E F0 MOVX @DPTR,A

800F 90 Fl 91 MOV DPTR,#0F191H ;Initialize

;USART

8012 F0 MOVX @DPTR,A

8013 F0 MOVX @DPTR,A

Page 29: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

29

8014 F0 MOVX @DPTR,A

8015 F0 MOVX @DFTR,A

8016 74 40 MOV A,#40H

8018 F0 MOVX @DPTR,A

8019 74 CE MOV A,#CEH

801B F0 MOVX @DPTR,A

801C 74 25 MOV A,#25H

801E F0 MOVX @DPTR,A

801F 90 90 00 MOV DPTR,#9000H ;Memory to

;store the

8022 C0 83 PUSH DPH ;Character

8024 C0 82 PUSH DPL

8026 90 Fl 91 GETCH: MOV DPTR,#0F191H

8029 E0 MOVX A,@DPTR

802A 54 02 ANL A,#02H

802C 60 F8 JZ GETCH

802E 90 Fl 90 MOV DPTR,#0F190H

8031 E0 MOVX A,@DPTR

8032 F5 F0 MOV 0F0H,A

8034 B4 1B 03 CJNE A,#1BH,SOUTPT

8037 02 00 03 LJMP 3

803A 90 Fl 91 SOUTPT: MOV DPTR,0F191H

803D E0 STATUS: MOVX A,@DPTR ;Get USART

;status

803E 54 01 ANL A,#0lH ;Receiver

;ready

8040 B4 01 FA CJNE A,#0lH,STATUS

8043 E5 F0 MOV A,0F0H

8045 90 Fl 90 MOV DPTR,#0F190H

8048 F0 MOVX @DPTR,A

8049 D0 82 POP DPL

804B D0 83 POP DPH

804D F0 MOVX @DPTR,A

804E A3 80 INC DPTR

8050 D1 FE SJMP GETCH

EXAMPLE PROGRAMS FOR ESA 31/51 TRAINERS

3.Program to Display "DEMO PROGRAM FOR 110 BAUD". Execute the

Program at 8000H.

CONTROL REGISTER = F183

DATA PORT = F190

COMMAND PORT = F191

ADDRESS OPCODE LABLE MNEMONIC COMMENTS

ORG 8000H

8000 74 36 MOV A,#36H

8002 90 F1 83 MOV DPTR,#0F183H

8005 F0 MOVX @DPTR,A ;Timer 0 in

;mode 3

Page 30: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

30

8006 90 F1 80 MOV DPTR,#0F180H

8009 74 69 MOV A,#69H

800B F0 MOVX @DPTR,A

800C 74 03 MOV A,#03H

800E F0 MOVX @DPTR,A

800F 90 F1 91 MOV DPTR,#0F191H ;Initialize

;USART

8012 F0 MOVX @DPTR,A

8013 F0 MOVX @DPTR,A

8014 F0 MOVX @DPTR,A

8015 F0 MOVX @DPTR,A

8016 74 40 MOV A,#40H ;Reset 8251

8018 F0 MOVX @DPTR,A

8019 74 CE MOV A,#0CEH

801B F0 MOVX @DPTR,A

801C 74 01 MOV A,#01H

801E F0 MOVX @DPTR,A

801F 90 90 00 MOV DPTR,#9000H

8022 79 00 MOV Rl,#00H

8024 C0 83 STATUS: PUSH DPH

8026 C0 82 PUSH DPL

8028 90 F1 91 MOV DPTR,#0F191H ;Get USART

802B E0 MOVX A,@DPTR ;status

802C 54 81 ANL A,#81H

802E D0 82 POP DPL

8030 D0 83 POP DPH

8032 B4 01 EF CJNE A,#01H,STATUS

8035 74 00 MOV A,#00H

8037 93 MOVC A,@A+DPTR

8038 B4 00 03 CJNE A,#00H,CONT

803B 02 00 00 LJMP 0

803E C0 83 CONT: PUSH DPH

8040 C0 82 PUSH DPL

8042 90 F1 90 MOV DPTR,#F190H

8045 F0 MOVX @DPTR,A

8046 D0 82 POP DPL

8048 D0 83 POP DPH

804A A3 INC DPTR

804B 80 D7 SJMP STATUS

ORG 9000H

9000 0A 0A 0A 0A 0A TABLE: DB 0AH,0AH,0AH,0AH,0AH

9005 0A 0A 0A DB 0AH,0AH,0AH

9008 20 20 20 20 20 DB 20H,20H,20H,20H,20H

900D 20 20 20 DB 20H,20H,20H

9010 44 45 4D 4F 20 DB 'DEMO PROGRAM FOR 110

;BAUD',0DH,00H

9015 50 52 4F 47 52

901A 41 4D 20 46 4F

901F 52 20 31 31 30

9024 20 42 41 55 44

9029 OD 00

Page 31: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

31

EXAMPLE PROGRAMS FOR ESA 31/51 TRAINERS

4.Program to Display "DEMO PROGRAM FOR ASYNCHRONOUS COMMUNICATION

IN INTERRUPT MODE" by using interrupt driven method.

Execute the Program at 8000H.

CONTROL REGISTER = F183

DATA PORT = F190

COMMAND PORT = F191

ADDRESS OPCODE LABLE MNOMONIC COMMENTS

ORG 8000H

8000 74 36 MOV A,#36H

8002 90 F1 83 MOV DPTR,#F183H ;TIMER 0 CMD

8005 F0 MOVX @DPTR,A

8006 90 F1 80 MOV DPTR,#F180H ;TIMER 0

;DATA

8009 74 0A MOV A,#0AH

800B F0 MOVX @DPTR,A

800C 74 00 MOV A,#00H

800E F0 MOVX @DPTR,A

800F 90 F1 91 MOV DPTR,#F191H ;Initialize

8012 F0 MOVX @DPTR,A ;USART

8013 F0 MOVX @DPTR,A

8014 F0 MOVX @DPTR,A

8015 F0 MOVX @DPTR,A

8016 74 40 MOV A,#40H

8018 F0 MOVX DPTR,A

8019 74 CE MOV A,#CEH

801B F0 MOVX @DPTR,A

801C 74 27 MOV A,#27H

801E F0 MOVX @DPTR,A

801F 90 81 50 MOV DPTR,#8150H

8022 75 A8 85 EN: MOV IE,#85H ;Enable INT1

ORG FFF3H

FFF3 02 90 00 LJMP STATUS

ORG 9000H

9000 C0 D0 STATUS: PUSH PSW

9002 74 00 BACK: MOV A,#00H

9004 93 MOVC A,@A+DPTR

9005 B4 00 03 CJNE A,#00H,NEXT

9008 02 00 00 LJMP 0

900B C0 83 NEXT: PUSH DPH

900D C0 82 PUSH DPL

900F 90 F1 92 MOV DPTR,#F192H

9012 F0 MOVX @DPTR,A

9013 D0 82 POP DPL

9015 D0 83 POP DPH

Page 32: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

32

9017 A3 INC DPTR

9018 D0 D0 POP PSW

901A 32 RETI

ORG 8150H

8150 0D 0A 0A 0A 0A DB 0DH,0AH,0AH,0AH,0AH,0AH

8155 0A 0A 0A 0A DB 0AH,0AH,0AH

8159 20 20 20 20 20 DB 20H,20H,20H,20H,20H

815E 20 20 20 DB 20H,20H,20H

8161 44 45 4D 4F 20 DB 'DEMO PROGRAM FOR

ASYNCHRONOUS’

8166 50 52 4F 47 52

816B 41 4D 20 46 4F

8170 52 20 41 53 59

8175 4E 43 48 52 4F

817A 4E 4F 55 53 20

817F 43 4F 4D 4D 55 DB 'COMMUNICATION IN

INTERRUPT MODE'

8184 4E 49 43 41 54

B189 49 4F 4E 20 49

818E 4E 20 49 4E 54

8193 45 52 52 55 50

8196 54 20 4D 4F 44

819D 45

819E 0D 00 DB 0DH,00H

EXAMPLE PROGRAM FOR ESA 31 TRAINER

5a.Initialize Timer 1 and Display the count on Data field of the

trainer Display. Execute the Program at 8000H. The program is in a

continuous Loop, press RESET key to come out of the loop.

CONTROL REGISTER = F183

DATA PORT = F190

COMMAND PORT = F191

ADDRESS OPCODE LABLE MNEMONIC COMMENTS

ORG 8000K

8000 74 76 MOV A,#76H ;TIMER1 in

;mode3

8002 90 Fl 83 MOV DPTR,#F183H

8005 F0 MOVX @DPTR,A

8006 74 FF MOV A,#FFH

8008 90 F1 81 MOV DPTR,#F18lH ; TIMER 1 DATA

800B F0 MOVX @DPTR,A

800C F0 MOVX @DPTR,A

800D 74 96 MOV A,#96H ; Load mode

;word

800F 90 Fl 83 MOV DPTR,#F183H

8012 F0 MOVX @DPTR,A

8013 74 FF MOV A,#FFH ; Data to

;counter2

Page 33: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

33

8015 90 Fl 82 ODT: MOV DPTR,#F182H ; Latch CMD

;word

8018 F0 MOVX @DPTR,A

8019 74 86 BACK: MOV A,#86H

801B 90 Fl 83 MOV DPTR,#F183H ; LATCH COMMAND

;WORD

801E F0 MOVX @DPTR,A

801F 90 Fl 82 MOV DPTR,F182H

8022 E0 MOVX A,@DPTR

8023 B4 00 02 CJNE A,#00H,NEXT

8026 80 ED SJMP ODT

8028 F5 60 NEXT: MOV 60H,A

802A 75 F0 00 MOV 0F0H,#00H

802D 12 01 9B LCALL 019BH

8030 79 FF MOV R1,#FFH

8032 7A FF X2: MOV R2,#FFH

8034 DA FE XI: DJNZ R2,X1

8036 D9 FA DJNZ R1,X2

8038 80 DF SJMP BACK

EXAMPLE PROGRAM FOR51E TRAINER

5b. Initialize Timer 1 and display the count on Data field of the

trainer display. Execute the program at 8000H.The program is in

continuous loop, press RESET Key to come out of the loop.

CONTROL REGISTER = F183

DATA PORT = F190

COMMAND PORT = F191

ADDRESS OPCODE LABLE MNOMONIC COMMENTS

ORG 8000H

8000 74 76 MOV A,#76H ;Timer 1 in

;mode 3

8002 90 F1 83 MOV DPTR,#F183H

8005 F0 MOVX @DPTR,A

8006 74 FF MOV A,#FFH

8008 90 F1 81 MOV DPTR,#F181H ;Timer I data

800B F0 MOVX @DPTR,A

800C F0 MOVX @DPTR,A

800D 74 96 MOV A,#96H ;Load mode word

800F 90 F1 83 MOV DPTR,#F183H

8012 F0 MOVX @DPTR,A

8013 74 FF MOV A,#FFH ;Data to

;counter 2

8015 90 F1 82 ODT: MOV DPTR,#F182H ;Latch CMD word

8018 F0 MOVX @DPTR,A

8019 74 86 BACK: MOV A,#86H

801B 90 F1 83 MOV DPTR,#F183H

801E F0 MOVX @DPTR,A

801F 90 F1 82 MOV DPTR,#F182H

Page 34: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

34

8022 E0 MOVX A,@DPTR

8023 B4 00 02 CJNE A,#00H,NEXT

8026 80 ED SJMP ODT

8028 F5 60 NEXT: MOV 71H,A

802A 75 F0 00 MOV 0F0H,#00H

802D 12 01 9B LCALL 13D2H

8030 79 FF MOV R1,#FFH

8032 7A FF X2: MOV R2,#FFH

8034 DA FE XI: DJN2 R2,X1

8036 D9 FA DJNZ R1,X2

8038 80 DF SJMP BACK

*****************************************************************

EXAMPLE PROGRAM FOR51E TRAINER

5c.Initialize Timer 1 and display the count on the console.

Execute The program at 8000H.The program is in continuous loop.

Press RESET Key to come out of the loop.

;CONTROL REGISTER =F183H

;DATA PORT =F190H

;COMMAND PORT =F191H

ADDRESS OPCODE LABLE MNOMONIC COMMENTS

ORG 8000H

8000 74 76 MOV A,#76H ;Timer 1 in

;mode 3

8002 90 F1 83 MOV DPTR,#F183H

8005 F0 MOVX @DPTR,A

8006 74 FF MOV A,#FFH

8008 90 F1 81 MOV DPTR,#F181H ;Timer 1 data

800B F0 MOVX @DPTR,A

800C F0 MOVX @DPTR,A

800D 74 96 MOV A,#96H ;Load mode word

800F 90 F1 83 MOV DPTR,#F183H

8012 F0 MOVX @DPTR,A

8013 74 FF MOV A,#FFH ;Data to

;counter 2

8015 90 F1 82 ODT: MOV DPTR,#F182H ;Latch CMD word

8018 F0 MOVX @DPTR,A

8019 74 86 BACK: MOV A,#86H

801B 90 F1 83 MOV DPTR,#F183H

801E F0 MOVX @DPTR,A

801F 90 F1 82 MOV DPTR,#F182H

8022 F0 MOVX A,@DPTR

8023 B4 00 02 CJNE A,#00H,NEXT

8026 80 ED SJMP ODT

8028 F5 71 NEXT: MOV 71H,A

802A 75 F0 00 MOV 0F0H,#00H

802D 12 13 9E LCALL 139EH

8030 74 08 MOV A,#08H

8032 12 11 AE LCALL 11AEH

Page 35: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

35

8035 74 08 MOV A,#08H

8037 12 11 AE LCALL 11AEH

803A 79 FF MOV R1,#FFH

803C 7A FF X2: MOV R2,#FFH

803E DA FE X1: DJNZ R2,X1

8040 D9 FA DJNZ R1,X2

8042 80 D5 SJMP BACK

END

6.0 Demonstration programs for 8086 series kits EXAMPLE PROGRAMS FOR ESA 86/88-3 AND 86/88-2 TRAINERS

1.PROGRAM TO DISPLAY "WELCOME TO ESA STUDY CARD"FOR 9600

BAUD. EXECUTE THE PROGRAM FROM 2000H

CONTROL REGISTER 8253 = 0080H

DATA PORT 8251 = 0090H

COMMAND PORT 8251 = 0092H

.

ORG 2000H

ADDR OPCODE MNEMONIC COMMENTS

0000:3000 B0 36 MOV AL,36

0000:3002 BA 86 00 MOV DX,0086

0000:3005 EE OUT DX,AL

0000:3006 BA 80 00 MOV DX,0080 ;Timer 0 in mode 3

0000:3009 B0 0A MOV AL,0A

0000:300B EE OUT DX,AL

0000:300C B0 00 MOV AL,00

0000:300E EE OUT DX,AL

0000:300F BC 00 30 MOV SP,3000

0000:3012 BA 92 00 MOV DX,0092 ;Initialize USART

0000:3015 EE OUT DX,AL

0000:3016 EE OUT DX,AL

0000:3017 EE OUT DX,AL

0000:3018 EE OUT DX,AL

0000:3019 E8 2E 00 CALL 304A

0000:301C B0 40 MOV AL,40 ;Reset 8251

0000:301E EE OUT DX,AL

0000:301F E8 28 00 CALL 304A

0000:3022 B0 CE MOV AL,CE

0000:3024 EE OUT DX,AL

0000:3025 E8 22 00 CALL 304A

0000:3028 B0 27 MOV AL,27

0000:302A EE OUT DX,AL

0000:302B E8 1C 00 CALL 304A

0000:302E BE 00 31 MOV SI,3100

0000:3031 BA 92 00 MOV DX,0092 ;Get USART status

0000:3034 EC IN AL,DX

Page 36: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

36

0000:3035 24 81 AND AL,81

0000:3037 3C 81 CMP AL,81

0000:3039 75 F6 JNE 3031

0000:303B 8A 04 MOV AL,[SI]

0000:303D 46 INC SI

0000:303E 3C 00 CMP AL,00

0000:3040 74 07 JE 3049

0000:3042 BA 90 00 MOV DX,0090

0000:3045 EE OUT DX,AL

0000:3046 E9 E8 FF JMP 3031

0000:3049 CC INT 03

ORG 2100H

0000:2100 0A 0A DB 0A,0A

0000:2102 0A 0A DB 0A,0A

0000:2104 0A 0A DB 0A,0A

0000:2106 0A 0A DB 0A,0A

0000:2108 20 20 DB 20,20

0000:210A 20 20 DB 20,20

0000:210C 20 20 DB 20,20

0000:210E 20 20 DB 20,20

0000:2110 57 45 4C 43 4F 4D ASC'WELCOME TO ESA STUDY CARD'

0000:2116 45 20 54 4F 20 45

0000:211C 53 41 20 53 54 55

0000:2122 44 59 20 43 41 52

0000:2128 44 00

2.PROGRAM TO RECEIVE CHARACTERS FROM THE USART AND DISPLAY IT ON

CONSOLE.PROGRAM EXECUTED FROM 2000H

CONTROL REGISTER 8253 = 0080H

DATA PORT 8251 = 0090H

COMMAND PORT 8251 = 0092H

.

ORG 2000H

ADDR OPCODE MNEMONIC COMMENTS

0000:2000 B0 36 MOV AL,36

0000:2002 BA 86 00 MOV DX,0086 ;Timer 0 in mode 0

0000:2005 EE OUT DX,AL

0000:2006 BA 80 00 MOV DX,0080

0000:2009 B0 0A MOV AL,0A ;Timer 0 DATA

0000:200B EE OUT DX,AL

0000:200C B0 00 MOV AL,00

0000:200E EE OUT DX,AL

0000:200F BC 00 30 MOV SP,3000

0000:2012 BA 92 00 MOV DX,0092 ;Initialize USART

0000:2015 EE OUT DX,AL

0000:2016 EE OUT DX,AL

Page 37: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

37

0000:2017 EE OUT DX,AL

0000:2018 EE OUT DX,AL

0000:2019 E8 43 00 CALL 205F

0000:201C B0 40 MOV AL,40 ;Reset 8251

0000:201E EE OUT DX,AL

0000:201F E8 3D 00 CALL 205F

0000:2022 B0 CE MOV AL,CE

0000:2024 EE OUT DX,AL

0000:2025 E8 37 00 CALL 205F

0000:2028 B0 27 MOV AL,27

0000:202A EE OUT DX,AL

0000:202B E8 31 00 CALL 205F

0000:202E BE 00 21 MOV SI,2100

0000:2031 BA 92 00 MOV DX,0092

0000:2034 EC IN AL,DX ;Get USART status

0000:2035 24 02 AND AL,02 ;Receiver Ready

0000:2037 74 F8 JE 2031

0000:2039 BA 90 00 MOV DX,0090 ;Get character from

0000:203C EC IN AL,DX ;USART

0000:203D 3C 1B CMP AL,1B

0000:203F 8A D8 MOV BL,AL

0000:2041 74 1B JE 205E

0000:2043 BA 92 00 MOV DX,0092

0000:2046 EC IN AL,DX

0000:2047 24 81 AND AL,81

0000:2049 3C 81 CMP AL,81

0000:204B 75 F6 JNE 2043

0000:204D 8A C3 MOV AL,BL

0000:204F BA 90 00 MOV DX,0090

0000:2052 EE OUT DX,AL

0000:2052 EE OUT DX,AL

0000:2053 88 04 MOV [SI],AL

0000:2055 46 INC SI

0000:2056 E9 D8 FF JMP 2031

0000:2059 EE OUT DX,AL

0000:205A 46 INC SI

0000:205B E9 E5 FF JMP 2043

0000:205E CC INT 03

0000:205F B9 02 00 MOV CX,0002

0000:2062 E2 FE LOOP 2062

0000:2064 C3 RET

3.PROGRAM TO DISPLAY "DEMO PROGRAM FOR 110 BAUD".EXECUTE PROGRAM FROM

2000H.

CONTROL REGISTER 8253 = 0080H

DATA PORT 8253 = 0090H

COMMAND PORT 8253 = 0092H

.

Page 38: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

38

ORG 2000H

ADDR OPCODE MNEMONIC COMMENTS

0000:2000 B0 36 MOV AL,36

0000:2002 BA 86 00 MOV DX,0086 ;Timer0 in mode 3

0000:2005 EE OUT DX,AL

0000:2006 BA 80 00 MOV DX,0080

0000:2009 B8 69 03 MOV AX,0369

0000:200C EE OUT DX,AL

0000:200D 8A C4 MOV AL,AH

0000:200F EE OUT DX,AL

0000:2010 B0 00 MOV AL,00

0000:2012 BA 92 00 MOV DX,0092 ;Initialization USART

0000:2015 EE OUT DX,AL

0000:2016 EE OUT DX,AL

0000:2017 EE OUT DX,AL

0000:2018 EE OUT DX,AL

0000:2019 B0 40 MOV AL,40 ;Reset 8251

0000:201B EE OUT DX,AL

0000:201C B0 CE MOV AL,CE

0000:201E EE OUT DX,AL

0000:201F B0 27 MOV AL,27

0000:2021 EE OUT DX,AL

0000:2022 BE 00 21 MOV SI,2100

0000:2025 BA 92 00 STATUS: MOV DX,0092 ;Get USART status

0000:2028 EC IN AL,DX

0000:2029 24 81 AND AL,81

0000:202B 3C 81 CMP AL,81

0000:202D 75 F6 JNE 2025

0000:202F 8A 04 MOV AL,[SI]

0000:2031 3C 00 CMP AL,00

0000:2033 74 08 JE 203D

0000:2035 BA 90 00 MOV DX,0090

0000:2038 EE OUT DX,AL

0000:2039 46 INC SI

0000:203A EB E9 JMP 2025

0000:203C CC OVER: INT 03

0000:2100 ORG 2100

0000:2100 0A 0A DB 0A,0A

0000:2102 0A 0A DB 0A,0A

0000:2104 0A 0A DB 0A,0A

0000:2106 0A 0A DB 0A,0A

0000:2108 20 20 DB 20,20

0000:210A 20 20 DB 20,20

0000:210C 20 20 DB 20,20

0000:210E 20 20 DB 20,20

0000:2110 44 45 4D 4F 20 50 ASC 'DEMO PROGRAM FOR 110 BAUD'

0000:2116 52 4F 47 52 41 4D

0000:211C 20 46 4F 52 20 31

0000:2122 31 30 20 42 41 55

0000:2128 44

0000:2129 00 DB 00

Page 39: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

39

4.PROGRAM TO INITIALIZE TIMER1 AND DISPLAY THE COUNT ON THE SERIAL

MODE.EXECUTE THE PROGRAM FROM 2000H.THE PROGRAM IS IN CONTINUOUS LOOP,

PRESS RESET KEY TO COME OUT OF THE LOOP.

CONTROL REGISTER 8253 = 0080H

DATA PORT 82153 = 0090H

COMMAND PORT 8251 = 0092H

ORG 2000H

ADDR OPCODE MNEMONIC COMMENTS

0000:2000 B0 76 MOV AL,76 ;Timer 1 CMD

0000:2002 BA 86 00 MOV DX,0086

0000:2005 EE OUT DX,AL

0000:2006 B0 FF MOV AL,FF

0000:2008 BA 82 00 MOV DX,0082 ;Timer 1 DATA

0000:200B EE OUT DX,AL

0000:200C EE OUT DX,AL

0000:200D B0 96 MOV AL,96 ;Timer 2 CMD

0000:200F BA 86 00 MOV DX,0086

0000:2012 EE OUT DX,AL

0000:2013 B0 FF MOV AL,FF

0000:2015 BA 84 00 ODT: MOV DX,0084 ;Latch command word

0000:2018 EE OUT DX,AL

0000:2019 B8 00 21 MOV AX,2100

0000:201C 9A 31 00 00 FB CALLS FB00:0031

0000:2021 9A 13 00 00 FB CALLS FB00:0013

0000:2026 B0 86 BACK: MOV AL,86

0000:2028 BA 86 00 MOV DX,0086

0000:202B EE OUT DX,AL

0000:202C BA 84 00 MOV DX,0084

0000:202F EC IN AL,DX

0000:2030 3C 00 CMP AL,00

0000:2032 74 E1 JE ODT

0000:2034 B4 00 MOV AH,00

0000:2036 9A 52 00 00 FB CALLS FB00:0052

0000:203B B9 FF FF MOV CX,FFFF

0000:203E E2 FE LOOP 203E

0000:2040 B0 08 MOV AL,08

0000:2042 9A 00 00 00 FB CALLS FB00:0000

0000:2047 9A 00 00 00 FB CALLS FB00:0000

0000:204C E9 D7 FF JMP BACK

0000:2100 ORG 2100

0000:2100 43 4F 55 4E 54 20 ASC 'COUNT VALUE:'

0000:2106 56 41 4C 55 45 3A

0000:210C 20

Page 40: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

40

0000:210D 00 DB 00

5.PROGRAM TO DISPLAY "DEMO PROGRAM FOR ASYNCHRONOUS COMMUNICATION IN

INTERRUPT MODE"BY USING INTERRUPT METHOD.EXECUTE PROGRAM FROM 2000H.

CONTROL REGISTER 8253 = 0080H

DATA PORT 8251 = 0090H

COMMAND PORT 8251 = 0092H

.

ORG 2000H

ADDR OPCODE MNEMONIC COMMENTS

0000:2000 B8 00 00 MOV AX,0000 ;Timer 0 in mode 3

0000:2003 8E C8 MOV CS,AX

0000:2005 8E C0 MOV ES,AX

0000:2007 BC 00 30 MOV SP,3000

0000:200A BE 50 21 MOV SI,2150

0000:200D 26 INIT: ES

0000:200E C7 06 24 01 00 21 MOVW @0124,2100

0000:2014 26 ES

0000:2015 C7 06 26 01 00 00 MOVW @0126,0000

0000:201B BA F4 FF MOV DX,FFF4

0000:201E B0 13 MOV AL,13

0000:2020 EE OUT DX,AL

0000:2021 BA F6 FF MOV DX,FFF6

0000:2024 B0 48 MOV AL,48

0000:2026 EE OUT DX,AL

0000:2027 B0 03 MOV AL,03

0000:2029 EE OUT DX,AL

0000:202A B0 FD MOV AL,FD

0000:202C EE OUT DX,AL

0000:202D FB STI

0000:202E B0 36 MOV AL,36

0000:2030 BA 86 00 MOV DX,0086 ;Timer 0 cmd

0000:2033 EE OUT DX,AL

0000:2034 BA 80 00 MOV DX,0080 ;Timer 0 data

0000:2037 B0 0A MOV AL,0A

0000:2039 EE OUT DX,AL

0000:203A B0 00 MOV AL,00

0000:203C EE OUT DX,AL

0000:203D BA 92 00 MOV DX,0092 ;Initialization USART

0000:2040 EE OUT DX,AL

0000:2041 EE OUT DX,AL

0000:2042 EE OUT DX,AL

0000:2043 EE OUT DX,AL

0000:2044 E8 1D 00 CALL 2064

0000:2047 B0 40 MOV AL,40 ;Reset 8251

0000:2049 EE OUT DX,AL

0000:204A E8 17 00 CALL 2064

Page 41: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

41

0000:204D B0 CE MOV AL,CE

0000:204F EE OUT DX,AL

0000:2050 E8 11 00 CALL 2064

0000:2053 B0 27 MOV AL,27

0000:2055 EE OUT DX,AL

0000:2056 8A 04 BACK: MOV AL,[SI]

0000:2058 3C 00 CMP AL,00

0000:205A 75 FA JNE BACK

0000:205C BA 92 00 MOV DX,0092 ;Get USART status

0000:205F EE OUT DX,AL

0000:2060 EE OUT DX,AL

0000:2061 EE OUT DX,AL

0000:2062 EE OUT DX,AL

0000:2063 CC INT 03

0000:2064 B9 02 00 DLY: MOV CX,0002

0000:2067 E2 FE LOOP 2067

0000:2069 C3 RET

0000:2100 ORG 2100

0000:2100 9C STATUS: PUSHF

0000:2101 8A 04 MOV AL,[SI]

0000:2103 46 INC SI

0000:2104 BA 90 00 MOV DX,0090

0000:2107 EE OUT DX,AL

0000:2108 9D POPF

0000:2109 FB STI

0000:210A CF OVER: IRET

0000:2150 ORG 2150

0000:2150 0D 0A DB 0D,0A

0000:2152 0A 0A DB 0A,0A

0000:2154 0A 0A DB 0A,0A

0000:2156 0A 0A DB 0A,0A

0000:2158 20 20 DB 20,20

0000:215A 20 20 DB 20,20

0000:215C 20 20 DB 20,20

0000:215E 20 20 DB 20,20

0000:2160 44 45 4D 4F 20 50 ASC 'DEMO PROGRAM FOR ASYNCHRONOUS'

0000:2166 52 4F 47 52 41 4D

0000:216C 20 46 4F 52 20 41

0000:2172 53 59 4E 43 48 52

0000:2178 4F 4E 4F 55 53 20

0000:217E 43 4A 4D 4D 55 4E ASC 'COMMUNICATION IN INTERRUPT MODE'

0000:2184 49 43 41 54 49 4F

0000:218A 4E 20 49 4E 20 49

0000:2190 4E 54 45 52 52 55

0000:2196 50 54 20 4D 4F 44

0000:219C 45

0000:219D 00 DB 00

.*******************************************************************************

Page 42: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

42

DEMONSTRATION EXAMPLES FOR 86E Trainer

8251 & 8253 REGISTER ADDRESSES The addresses for the 8253 registers on this card for use with ESA 86/88E Trainer are as

follows:

Timer 0 - FFC0H

Timer 1 - FFC2H

Timer 2 - FFC4H

Command Register - FFC6H

The addresses for the 8251 registers on this card for use with ESA 86/88E Trainer are as

follows:

Command/Status Register - FFCAH

Data Register - FFC8H

Example 1. This program initializes the 8251 for 9600 baud and displays the message 'WELCOME TO ESA 8251/53 STUDY CARD' on the console. Enter and execute the

program from 0:2000H location

ADDRESS OP-CODES LABELS MNEMONICS COMMENTS

0000:2000 M53 EQU 0FFC6

0000:2000 TM0 EQU 0FFC0

0000:2000 M51 EQU 0FFCA

0000:2000 V51 EQU 0FFC8

0000:2000 B0 36 MOVB AL,36 ;Initialize

;TIMER 0

0000:2002 BA C6 FF MOVW DX,M53 ;for Mode 3

;operation

0000:2005 EE OUTB DX,AL

0000:2006 BA C0 FF MOVW DX,TMO

0000:2009 B0 0A MOVB AL,0A

0000:200B EE OUTB DX,AL ;Load TIMER 0

;count

0000:200C B0 00 MOVB AL,00 ;for 9600 baud

0000:200E EE OUTB DX,AL

0000:200F BC 00 30 MOVW SP,3000

0000:2012 BA CA FF MOVW DX,M51

0000:2015 EE OUTB DX,AL ;Reset 8251

0000:2016 EE OUTB DX,AL

0000:2017 EE OUTB DX,AL

0000:2018 EE OUTB DX,AL

0000:2019 E8 2E 00 CALL DLY

Page 43: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

43

0000:201C B0 40 MOVB AL,40 ;Initialize 8251

;for asynchronous

0000:201E EE OUTB DX,AL ;16x baud

0000:201F E8 28 00 CALL DLY ;8 data bits, no

0000:2022 B0 CE MOVB AL,0CE ;parity

0000:2024 EE OUTB DX,AL

0000:2025 E8 22 00 CALL DLY

0000:2028 B0 27 MOVB AL,27

0000:202A EE OUTB DX,AL

0000:202B E8 1C 00 CALL DLY

0000:202E BE 00 21 MOVW SI,2100

0000:2031 BA CA FF STS: MOVW DX,M51

0000:2034 EC INB AL,DX ;Get USART status

;for Transmitter

0000:2035 24 81 ANDB AL,81 ;ready &

0000:2037 3C 81 CMPB AL,81 ;DSR active

0000:2039 75 F6 JNE STS

0000:203B 8A 04 MOVB AL,[SI] ;If yes, transmit

0000:203D 46 INCW SI ;stored character

0000:203E 3C 00 CMPB AL,00

0000:2040 74 07 JE OVR

0000:2042 BA C8 FF MOVW DX,V51

0000:2045 EE OUTB DX,AL

0000:2046 E9 E8 FF JMP STS

0000:2049 CC OVR: INT 3

0000:204A B9 02 00 DLY: MOVW CX,2

0000:204D E2 FE LOOP 204D

0000:204F C3 RET

ORG 2100 ;Display msg TBL 0000:2100 0D 0A 20 20 57 45

0000:2106 4C 43 4F 4D 45 20 ASC'WELCOME TO ESA STUDY CARD'

0000:210C 54 4F 20 45 53 41

0000:2112 20 53 54 55 44 59

0000:2118 20 43 41 52 44 0D 00

Example 2.Program to receive characters from the USART and display

it on the console as well as store it in memory location from

0:2100H location onwards. Press <Esc> to stop receiving characters

and exit from the loop.

ADDRESS OP-CODES LABELS MNEMONICS COMMENTS 0000:2000 M53 EQU 0FFC6

0000:2000 TM0 EQU 0FFC0

0000:2000 M51 EQU 0FFCA

0000:2000 V51 EQU 0FFC8

0000:2000 B0 36 MOVB AL,36

0000:2002 BA C6 FF MOVW DX,M53 ;Initialize

;TIMER 0

0000:2005 EE OUTB DX,AL ;for Mode 3

operation

0000:2006 BA C0 FF MOVW DX,TM0

0000:2009 B0 0A MOVB AL,0A ;Load TIMER 0

;count

Page 44: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

44

0000:200B EE OUTB DX,AL ;for 9600 baud

0000:200C B0 00 MOVB AL,00

0000:200E EE OUTB DX,AL

0000:200F BC 00 30 MOVW SP,3000

0000:2012 BA CA FF MOVW DX,M51 ;Reset 8251

0000:2015 EE OUTB DX,AL

0000:2016 EE OUTB DX,AL

0000:2017 EE OUTB DX,AL

0000:2018 EE OUTB DX,AL

0000:2019 E8 43 00 CALL DLY

0000:201C B0 40 MOVB AL,40 ;Initialize 8251

;for asynchronous

0000:201E EE OUTB DX,AL ;16x baud, 8 data

0000:201F E8 3D 00 CALL DLY ;bits, no parity

0000:2022 B0 CE MOVB AL,0CE

0000:2024 EE OUTB DX,AL

0000:2025 E8 37 00 CALL DLY

0000:2028 B0 27 MOVB AL,27

0000:202A EE OUTB DX,AL

0000:202B E8 31 00 CALL DLY

0000:202E BE 00 21 MOVW SI,2100 ;Initialize

; Memory to

0000:2031 BA CA FF GCH: MOVW DX,M51 ;store character

0000:2034 EC INB AL,DX ;Get USART status

0000:2035 24 02 ANDB AL,02 ;Receiver ready ?

0000:2037 74 F8 JZ GCH ;No, wait

0000:2039 BA C8 FF MOVW DX,V51 ;Yes, Get

; Character

0000:203C EC INB AL,DX ;from USART

0000:203D 3C 1B CMPB AL,27 ;If char = <Esc>

0000:203F 8A D8 MOVB BL,AL ;Exit

0000:2041 74 1B JE OVR

0000:2043 BA CA FF OPT: MOVW DX,M51

0000:2046 EC INB AL,DX ;Get USART status

0000:2047 24 81 ANDB AL,81 ;Transmitter

;Ready

0000:2049 3C 81 CMPB AL,81

0000:204B 75 F6 JNE OPT ;No, Wait

0000:204D 8A C3 MOVB AL,BL ;Send same

;character

0000:204F BA C8 FF MOVW DX,V51 ;to USART

0000:2052 EE OUTB DX,AL

0000:2053 88 04 MOVB [SI],AL

0000:2055 46 INCW SI

0000:2056 E9 D8 FF JMP GCH

0000:2059 EE OUTB DX,AL

0000:205A 46 INCW SI

0000:205B E9 E5 FF JMP OPT

0000:205E CC OVR: INT 3

0000:205F B9 02 00 DLY: MOVW CX,2

0000:2062 E2 FE LOOP 2062

Page 45: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

45

0000:2064 C3 RET

Example 3. This program initializes the 8253 timer in Mode 3 (Square wave

Generator) and displays the count on the console. Press RESET to exit from the

program. Execute this program from 0:2000H location in Serial Mode.

ADDRESS OP-CODES LABELS MNEMONICS COMMENTS 0000:2000 M53 EQU 0FFC6

0000:2000 TM2 EQU 0FFC4

0000:2000 TM0 EQU 0FFC0

0000:2000 B0 76 MOVB AL,76 ;Initialize

;TIMER 1

0000:2002 BA C6 FF MOVW DX,M53 ;for Mode 3

;operation

0000:2005 EE OUTB DX,AL

0000:2006 B0 FF MOVB AL,0FF

0000:2008 BA C2 FF MOVW DX,TM1 ;Load TIMER 1

;data

0000:200B EE OUTB DX,AL ;LSB first

0000:200C EE OUTB DX,AL ; Load MSB

0000:200D B0 96 MOVB AL,96 ;Initialize

;TIMER 2

0000:200F BA C6 FF MOVW DX,M53

0000:2012 EE OUTB DX,AL

0000:2013 B0 FF MOVB AL,0FF

0000:2015 BA C4 FF ODT: MOVW DX,TM2 ;Load TIMER 2

; Data

0000:2018 EE OUTB DX,AL

0000:2019 9A 31 00 00 FE CALLS 0FE00:0031 ;Display message

0000:201E BE 60 20 MOVW SI,2060 ;Timer Count = '

0000:2021 9A AF 01 00 FE CALLS 0FE00:01AF ;on console

0000:2026 B0 86 BCK: MOVB AL,86

0000:2028 BA C6 FF MOVW DX,M53 ;Latch Command

; Word

0000:202B EE OUTB DX,AL

0000:202C BA C4 FF MOVW DX,TM2 ;Read count

0000:202F EC INB AL,DX

0000:2030 3C 00 CMPB AL,00

0000:2032 74 E1 JE ODT

0000:2034 B4 00 MOVB AH,00

0000:2036 9A 52 00 00 FE CALLS 0FE00:0052 ;Display

;count value

0000:203B B0 08 MOVB AL,08 ;on console

0000:203D 9A 00 00 00 FE CALLS 0FE00:0000

0000:2042 9A 00 00 00 FE CALLS 0FE00:0000

0000:2047 B9 00 04 MOVW CX,0400

0000:204A E2 FE LOOP 204A

0000:204C EB D8 JMP BCK ;Repeat

;continuously

ORG 2060

0000:2060 54 49 4D 45 52

Page 46: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

46

0000:2065 20 43 4F 55 4E

0000:206A 54 20 00 ASC ' TIMER COUNT = ‘

DB 00

Example 4. This program initializes the 8251 for 110 baud and

displays the following message on the console. Enter and execute

the program from 0:2000H location.

ESA 8251/53 STUDY CARD

DEMONSTRATION PROGRAM FOR 110 BAUD

Note: Set receiving terminal to receive data at 110 baud

ADDRESS OP-CODES LABELS MNEMONICS COMMENTS 0000:2000 M53 EQU 0FFC6

0000:2000 TM0 EQU 0FFC0

0000:2000 M51 EQU 0FFCA

0000:2000 V51 EQU 0FFC8

0000:2000 B0 36 MOVB AL,36

0000:2002 BA C6 FF MOVW DX,M53 ;Initialize

;timer 0

0000:2005 EE OUTB DX,AL ;For mode 3

;operation

0000:2006 BA C0 FF MOVW DX,TMO

0000:2009 B0 69 MOVB AL,69 ;Load TMER 0

;Count

0000:200B EE OUTB DX,AL ;for 110 baud

0000:200C B0 03 MOVB AL,03

0000:200E EE OUTB DX,AL

0000:200F BC 00 30 MOVW SP,3000

0000:2012 B0 00 MOVB AL,00

0000:2014 BA CA FF MOVW DX,M51 ;Reset USART

0000:2017 EE OUTB DX,AL

0000:2018 EE OUTB DX,AL

0000:2019 EE OUTB DX,AL

0000:201A EE OUTB DX,AL

0000: 201B E8 2E 00 CALL DLY

0000: 201E B0 40 MOVB AL,40

0000: 2020 EE OUTB DX,AL

0000: 2021 E8 28 00 CALL DLY

0000: 2024 B0 CE MOVB AL,OCE

0000: 2026 EE OUTB DX/AL

0000: 2027 E8 22 00 CALL DLY

0000: 202A B0 27 MOVB AL,27

0000: 202C EE OUTB DX,AL

0000: 202D E8 1C 00 CALL DLY

0000: 2030 BE 00 21 MOW SI/2100

0000: 2033 BA CA FF STS: MOVW DX,M51 ;Get USART status

;for transmitter

Page 47: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

47

0000: 2036 EC INB AL,DX ;ready and

0000: 2037 24 81 ANDB AL/81 ;DSR active

0000: 2039 3C 81 CMPB AL/81 ;No/ wait till it

0000: 203B 75 F6 JNE STS ;becomes active

0000: 203D 8A 04 MOVB AL,[SI] ;If yes, transmit

0000: 204F 46 INCW SI ;stored character

0000: 2040 3C 00 CMPB AL,00

0000: 2042 74 06 JE OVER

0000: 2044 BA C8 FF MOVW DX,V51

0000: 2047 EE OUTB DX,AL

0000: 2048 EB E9 JMP STS

0000: 204A CC OVR: INT 3

0000: 204B B9 02 00 DLY: MOVW CX,2

0000: 204E E2 FE LOOP 204E

0000: 2050 C3 RET

ORG 2100 ;Display look-up

;table

0000: 2100 44 45 4D 4F ASC’DEMO PROGRAM FOR 110 BAUD’

0000: 2104 20 50 52 4F

0000:2108 47 52 41 4D

0000:210C 20 46 4F 52

0000:2110 20 31 31 30

0000:2114 20 42 41 55

0000:2115 44 0D 00

Page 48: 8251 AND 8253 - Electro Systems Associates ·  · 2016-08-248251 AND 8253 PROGRAMMABLE ... microprocessors like 8085, Z-80, 8031,8086/88,68000 and 80196. ESA offers a variety of

User’s Manual for 8251/8253 study card

48