![background image](http://html1.mh-extra.com/html/keithley/dda-06/dda-06_user-manual_3957614031.webp)
6-4
Programming
Example 2: Read/Write the Digital I/O Ports
First, set ports A, B, and C as input or output by writing to the Control
register, at Base
Address
+Fh. Most applications require all eight bits in
each register to be set as input or output. Table 6-3 provides a small set of
the codes that must be written to the Control register for input/output
possibilities.
For more code information, refer to the Intel 8255 data sheet (Intel
Corporation, Literature Department, 3065 Bowers Avenue, Santa Clara,
California 95051).
The following program sets port A as an output while setting ports B and
C as inputs. The program then reads data from ports B and C, performs a
logical OR on the data, and writes the result to port A. Refer to the I/O
map (Table 6-1 on page 6-1) for register locations.
Let BASE = the base address of the board as a decimal number.
05 BASE = 768
’Set base address to 768
10 OUT(BASE + &H0F), &H8B
’PA output, PB and PC input
20 B% = INP(BASE + &H0D)
’Read PB, data in B%
30 C% = INP(BASE + &H0E)
’Read PC, data in C%
40 A% = B% or C%
’OR PB and PC, data in A%
50 OUT(BASE + &H0C), A%
’Write data to PA
Table 6-3. Control Code Requirements for Port I/O Settings
PA
PB
PC
Control Code
Input
Input
Input
9Bh
Input
Input
Output
92h
Input
Output
Input
99h
Input
Output
Output
90h
Output
Input
Input
8Bh
Output
Input
Output
82h
Output
Output
Input
89h
Output
Output
Output
80h
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com