Appendix D Register-Level Programming
©
National Instruments Corporation
D-17
PC-DIO-96/PnP User Manual
unsigned int porta, portb, portc, cnfg;
char valread;
/* Variable to store data read from a port */
/* Calculate register addresses */
porta = BASE_A APORTAoffset;
portb = BASE_A APORTBoffset;
portc = BASE_A APORTCoffset;
cnfg = BASE_A ACNFGoffset;
/* EXAMPLE 1–port A input */
outp(cnfg,0xB0);
/* Port A is an input in mode 1. */
while (!(inp(portc) & 0x20));
/* Wait until IBFA is set,
indicating that data has been
loaded in port A. */
valread = inp(porta);
/* Read the data from port A. */
/* EXAMPLE 2–Port B input */
outp(cnfg,0x86);
/* Port B is an input in mode 1. */
while (!(inp(portc) & 0x02));
/* Wait until IBFB is set,
indicating that data has been
loaded in port B. */
valread = inp(portb);
}
Mode 1—Strobed Output
The control word written to the CNFG Register to configure port A for
output in mode 1 is shown as follows. Bits PC4 and PC5 of port C can
be used as extra input or output lines.
The control word written to the CNFG Register to configure port B for
output in mode 1 is shown as follows. Notice that port B does not have
extra input or output lines from port C.
D2
D1
D0
D3
D7
D6
D5
D4
1 = input
0 = output
Port C bits PC4 and PC5
1
0
1/0
X
X
X
1
0
Содержание PC-DIO-96/PnP
Страница 46: ......
Страница 47: ......
Страница 48: ......
Страница 49: ......
Страница 50: ......
Страница 51: ......
Страница 52: ......
Страница 53: ......
Страница 54: ......
Страница 55: ......
Страница 56: ......
Страница 57: ......
Страница 58: ......
Страница 59: ......
Страница 60: ......
Страница 61: ......
Страница 63: ......
Страница 64: ......
Страница 65: ......
Страница 66: ......
Страница 67: ......
Страница 68: ......
Страница 69: ......
Страница 70: ......
Страница 71: ......
Страница 72: ......
Страница 73: ......