Appendix C Register-Level Programming
©
National Instruments Corporation C-17 PC-DIO-24/PnP Us er Manual
/* EXAMPLE 2–port B output */
outp(cnfg,0x84); /* Port B is an output in mode 1.*/
while (!(inp(portc) & 0x02)); /* Wait until OBFB* is set,
indicating that the data last
written to port B has been
read.*/
outp(portb,0x34); /* Write the data to port B. */
}
Mode 2—Bidirectional BusMode 2 has an 8-bit bus that can transfer both input and output data
without changing the configuration. The data transfers are synchronized
with handshaking lines in port C. This mode uses only port A; however,
port B can be used in either mode 0 or mode 1 while port A is configured
for mode 2.
The control word written to the CNFG Register to configure port A as
a bidirectional data bus in mode 2 is shown as follows. If port B is
configured for mode 0, then PC2, PC1, and PC0 of port C can be used
as extra input or output lines.
Figure C-4. Port A Configured as a Bidirectional Data Bus in Mode 2
D2 D1 D0D3D7 D6 D5 D4
1 = input
0 = output
Port C
(PC2-PC0)
11/0
XXX1
1 = input
0 = output
Port B
0 = mode 0
1 = mode 1
Group B Mode
1/0 1/0