Sie sind auf Seite 1von 10

8051 C Programming For 8255

TABLE OF CONTENT

Programming of 8255
8255 features
Mode selection of the 8255
Examples
Conclusion
Reference

1
ECE Department,SRMGPC,LUCKNOW
8051 C Programming For 8255

PROGRAMMING THE 8255

The process of connecting the 8031/51 to external memory, two ports, PO and P2, are lost. In
this chapter we show how to expand the I/O ports of the 8031/51 by connecting it to an 8255
chip. The connection of the 8031/51 to an 8255 is shown. In Section 15.2, the 8255 is
programmed as a simple I/O port for connection with devices such as LCDs, stepper motors,
and ADCs. 8051 C programming of the 8255 is discussed.
PROGRAMMING THE 8255
In this section we study the 8255 chip, one of the most widely used I/O chips. We first describe
its features and then show the connection between the 8031/51 and 8255 chips.

8255 features
The 8255 is a 40-pin DIP chip (see Figure 15-1). It has three separately accessible ports. The
ports are each 8-bit, and are named A, B, and C. The individual ports of the 8255 can be
programmed to be input or output, and can be changed dynamically. In addition, 8255 ports,
have handshaking capability, thereby allowing interface with devices that also have
handshaking signals, such as printers. The handshaking capability of the 8255 is not discussed
since it is no longer used.

2
ECE Department,SRMGPC,LUCKNOW
8051 C Programming For 8255

PAO PA7
The 8-bit port A can be programmed as all input, or as all output, or all bits as bidirectional
input/output.
PBO PB7
The 8-bit port B can be programmed as all input or as all output. Port B cannot be used as a
bidirectional port.
PCO-PC7
This 8-bit port C can be all input or all output. It can also be split into two parts, CU (upper
bits PC4 PC7) and CL (lower bits PCO PC3). Each can be used for input or output.

RD and WR
These two active-low control signals are inputs to the 8255. The RD and WR signals from the
8031/51 are connected to these inputs.
DO D7 data pin
The data pins of the 8255 are connected to the data pins of the microcontroller allowing it to
send data back and forth between the controller and the 8255 chip.
RESET

3
ECE Department,SRMGPC,LUCKNOW
8051 C Programming For 8255

This is an active-high signal input into the 8255 used to clear the control register. When RESET
is activated, all ports are initialized as input ports. In many designs this pin is connected to the
RESET output of the system bus or grounded to make it inactive. Like all 1C input pins, it
should not be left unconnected.
AO,A1, andCS
While CS (chip select) selects the entire chip, it is AO and Al that select specific ports. These
three pins are used to access ports A, B, C, or the control register as shown in Table 15-1. Note
that CS is active-low.
Mode selection of the 8255
While ports A, B, and C are used to input or output data, it is the control register that must be
programmed to select the operation mode of the three ports. The ports of the 8255 can be
programmed in any of the following modes.
1. Mode 0, simple I/O mode. In this mode, any of the ports A, B, CL, and CU can
be programmed as input or output. In this mode, all bits are out or all are in. In
other words, there is no such thing as single-bit control as we have seen in
PO P3 of the 8051. Since the vast majority of applications involving the 8255
use this simple I/O mode, we will concentrate on this mode in this chapter.
2. Mode 1. In this mode, ports A and B can be used as input or output ports with
handshaking capabilities. Handshaking signals are provided by the bits of port
C.
3. Mode 2. In this mode, port A can be used as a bidirectional I/O port with hand
shaking capabilities whose signals are provided by port C. Port B can be used
either in simple I/O mode or handshaking mode 1.
4. BSR (bit set/reset) mode. In this mode, only the individual bits of port C can
be programmed.
Figure 15-3 shows the control word for mode selection of the 8255.

4
ECE Department,SRMGPC,LUCKNOW
8051 C Programming For 8255

8255 Control Word Format (I/O Mode)


Simple I/O programming
Intel calls mode 0 the basic input/output mode. The more commonly used term is simple I/O. In
this mode, any of ports A, B, or C can be programmed as input or output. It must be noted that
in this mode, a given port cannot be both an input and output port at the same time.

5
ECE Department,SRMGPC,LUCKNOW
8051 C Programming For 8255

Example 1
Write a C program to send 55H and AAH to all ports of the 8255 continuously. Assume the
base address of the 8255 is 4000H.
Solution:

6
ECE Department,SRMGPC,LUCKNOW
8051 C Programming For 8255

Example 15-7
Write a C program to get data from PA and send it to both ports B and C. Use a base address
of 4000H for the 8255.

Example 15-8
Write a C program to move the stepper motor shown in Figure 15-9 clockwise. Use a base
address of 4000H for the 8255.
Solution:

7
ECE Department,SRMGPC,LUCKNOW
8051 C Programming For 8255

8
ECE Department,SRMGPC,LUCKNOW
8051 C Programming For 8255

CONCLUSION

This term paper described how to expand the I/O ports of the 8031/51 by connecting it to an
8255 chip. The 8255 could then be programmed as a simple I/O port to control interfaced
devices such as stepper motors, LCDs, and ADC devices.
The 8255 has 3 ports. Ports A and B are 8-bit bidirectional ports. The 8-bit port C can be
programmed as one 8-bit port or two 4-bit ports. The various operation modes of the 8255 are
selected by the control register. Various address decoding techniques were demonstrated to
program the 8255 control register, select ports, and set the control register. In addition,
numerous program examples were given of 8051/31 instructions to control devices such as
LCDs, stepper motors, and ADC devices that were interfaced via the 8255.

9
ECE Department,SRMGPC,LUCKNOW
8051 C Programming For 8255

REFERENCES

http://what-when-how.com/8051-microcontroller/8051-c-programming-for-the-8255/
http://what-when-how.com/8051-microcontroller/programming-the-8255/
https://www.google.co.in/search?q=8051+C+PROGRAMMING+FOR+8255&rlz=1C
1RLNS_enIN714IN714&oq=8051++C+PROGRAMMING+FOR+8255&aqs=chrom
e..69i57.24880j0j7&sourceid=chrome&ie=UTF-8

10
ECE Department,SRMGPC,LUCKNOW

Das könnte Ihnen auch gefallen