The Microcontroller Idea Book - Jan Axelson's Lakeview Research
The Microcontroller Idea Book - Jan Axelson's Lakeview Research
The Microcontroller Idea Book - Jan Axelson's Lakeview Research
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Inputs and Outputs<br />
An 8255 Interface<br />
Figure 6-6 shows an 8255 (U15) accessed at FC00h in the 8052-BASIC system. Many of<br />
the pins connect directly to matching signals in the system: D0-D7 connect to the system’s<br />
data bus, A0 and A1 connect to the lowest two address lines, and the RD and WR inputs connect<br />
to U2’s matching outputs. CS connects to pin 7 of U11 (from Figure 6-2), which selects the<br />
chip at addresses from FC00h to FFFFh. U15 actually uses four of these addresses: FC00h<br />
through FC03h.<br />
U15’s RESET input is controlled by the same RESET signal at pin 9 of the 8052-BASIC. <strong>The</strong><br />
three new I/O ports are Port A, Port B, and Port C. Address lines A0 and A1 select the port<br />
to be accessed, with Port A at FC00h, Port B at FC01h, and Port C at FC02h.<br />
<strong>The</strong> port pins should connect only to voltages in the range -0.5V to +6.5V. According to<br />
Intel’s data sheet, the 82C55 has bus-hold circuits that eliminate the need for external<br />
pull-ups on its CMOS inputs.<br />
<strong>The</strong> Control Word<br />
You configure the 8255 by writing a control word to a control register addressed at FC03h.<br />
<strong>The</strong> control word has two functions: selecting modes of operation, and setting and clearing<br />
port bits. When bit 7 of a byte written to the control register is 1, the control word selects<br />
modes of operation for each port and determines whether a port is input, output, or<br />
bidirectional. Many combinations of modes and I/O are available. When bit 7 of a byte<br />
written to the control register is 0, the control word sets and clears individual bits of Port C.<br />
<strong>The</strong> control word is write-only; you can’t read it.<br />
Mode Setting<br />
Figure 6-7, from Intel’s data sheet, describes the mode-set control word. <strong>The</strong> ports are<br />
divided into two groups. Group A consists of Port A plus bits 4-7 of Port C, and Group B<br />
consists of Port B plus bits 0-3 of Port C. This grouping enables Ports A and B to each use<br />
half of Port C for handshaking, or control, signals.<br />
To set the mode, bit 7 of the control word must be 1. Bit 2 selects mode 0 or 1 for Group B,<br />
and bits 5 and 6 select mode 0, 1, or 2 for Group A. Bits 0, 1, 3, and 4 select whether a port<br />
is input or output, with each half of Port C selected independently.<br />
<strong>The</strong> simplest mode is Mode 0, Basic Input/Output. <strong>The</strong> ports behave very much like the<br />
inputs and outputs at U12 and U14. Outputs are latched, so they change only when written<br />
to. <strong>The</strong> inputs are not latched, so the present, or current, value of the input is always read.<br />
This statement configures all ports as inputs in mode 0:<br />
<strong>The</strong> <strong>Microcontroller</strong> <strong>Idea</strong> <strong>Book</strong> 103