Programming
Chapter 4
AT-DIO-32F User Manual
4-38
© National Instruments Corporation
Mode 0 Programming
Whenever the AT-DIO-32F is started up, each digital I/O port is configured as a read port. The
status of the lines connected to each port can be determined by reading that port. To configure a
port as a write port, the port's corresponding WRITE bit must be set. If a write port is read, the
result is the data currently driven on that port. Any value written to a write port is then driven on
the corresponding digital I/O lines. When the WRITE bit for a port is cleared, the port is once
again configured as a read port.
For example, to use Ports A and B as write ports, write hex 2400 to the CFG3 Register. Clearing
bit 10 and bit 13 of the CFG3 Register configures Ports A and B as read ports. Similarly, writing
hex 4800 to the CFG3 Register configures Ports C and D as write ports, and clearing bit 11 and
bit 14 of the CFG3 Register configures Ports C and D as read ports. Each port can be assigned a
direction independently.
Mode 1 Programming
Each group of ports has its own set of handshaking lines. Group 1 (Ports A and B) handshaking
lines are REQ1 and ACK1. Group 2 (Ports C and D) handshaking lines are REQ2 and ACK2.
The individual ports in a group must be enabled for handshaking within each group by setting
DIOAEN, DIOBEN, DIOCEN, and DIODEN. For 8-bit transfers, only one port should be
enabled for handshaking in a group. For 16-bit transfers, both ports in a group should be
enabled.
The direction of handshaking for each group is determined by the corresponding WRITE bit. If
data is to be driven by the group, the corresponding WRITE bit must be set. If a write port is
read, the result is the data currently driven on that port. If data is to be received by the group, the
corresponding WRITE bit must be cleared.
Any ports not enabled for handshaking can be used for Mode 0 operations, that is, for reading
additional status data or for driving additional control lines. For example, if Port B is enabled for
handshaking and is configured as a read port, Port A can be used to read or write data lines in
Mode 0 operations.
For example, to set up Group 1 as a 16-bit handshaking write port with REQ1 and ACK1 as
negative logic, follow these steps:
1. Write hex 0644 to the CFG1 Register to set up the handshaking mode.
2. Write hex 2400 to the CFG3 Register to set up the group as a write port (if the port is a read
port, skip this step).
Reading the STAT Register returns the status of REQ1, ACK1, and the DRDY1 bit.
The polarity of the handshaking lines for each group is programmable. If the external signal
connected to REQ1 or REQ2 is active low, INVRQ1 or INVRQ2, respectively, should be set. If
the external signal connected to ACK1 or ACK2 is active low, INVACK1 or INVACK2,
respectively, should be set.
The status of REQ1, REQ2, ACK1, and ACK2 as seen at the digital I/O connector can be read
from the STAT Register. If handshaking is not enabled, the ACK lines can be used as extra
Содержание AT-DIO-32F
Страница 19: ......
Страница 101: ......
Страница 102: ......
Страница 123: ......
Страница 124: ......
Страница 125: ......
Страница 126: ......
Страница 127: ......
Страница 128: ......
Страница 129: ......
Страница 130: ......
Страница 131: ......
Страница 132: ......
Страница 133: ......
Страница 134: ......
Страница 135: ......
Страница 136: ......
Страница 137: ......
Страница 138: ......
Страница 139: ......
Страница 140: ......
Страница 141: ......
Страница 142: ......
Страница 143: ......