7
110 data% = INP(ba7)
120 ........
3. Read in data of port 0 (In C language)
........
i = inportb(b0); /* data in i */
........
The following examples show you how to write data to an
output port:
Example 4: Write 20h to port 4 (In assembly language)
........
MOV DX,ba4
DX points to port 5 address
MOV AL,20H
;Initialize data
OUT DX,AL
;Write data out
........
Example 5: Set bit 6 of port 1 to "1", other bits not
affected (In BASIC language)
100 ........
110 data% = INP(ba1)
120 OUT (ba1, data% OR &H40)
130 ........
Example 6:. Write 55h to port 3 (In C language)
........
outportb(b3,0x55);
........
CHAPTER 4
SIGNAL CONNECTION
Figure 4-1 shows the connection of the digital I/O.
DO
DI
AR-B2201
Other TTL device
GND
Ground
Vcc
Figure 4-1 Digital I/O Connection