Chapter 4
Register-Level Programming
© National Instruments Corporation
4-9
PC-DIO-24 User Manual
Mode 1 Input Programming Example
Main() {
#define BASE_ADDRESS
0x210
/* Board located at address 210. */
#define PORTAoffset
0x00
/* Offset for port A */
#define PORTBoffset
0x01
/* Offset for port B */
#define PORTCoffset
0x02
/* Offset for port C */
#define CNFGoffset
0x03
/* Offset for CNFG */
register unsigned int porta, portb, portc, cnfg;
char valread;
/* Variable to store data read from a
port */
/* Calculate register addresses. */
porta = BASE_A PORTAoffset;
portb = BASE_A PORTBoffset;
portc = BASE_A PORTCoffset;
cnfg = BASE_A CNFGoffset;
/* 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 when
port A uses mode 1 output.
1
0
1
0
1/0
X
X
X
7
6
5
4
3
2
1
0
1 = input
0 = output
Port C bits PC4 and PC5
Summary of Contents for PC-DIO-24
Page 51: ...Appendix C OKI 82C55A Data Sheet PC DIO 24 User Manual C 2 National Instruments Corporation...
Page 52: ...Appendix C OKI 82C55A Data Sheet National Instruments Corporation C 3 PC DIO 24 User Manual...
Page 53: ...Appendix C OKI 82C55A Data Sheet PC DIO 24 User Manual C 4 National Instruments Corporation...
Page 54: ...Appendix C OKI 82C55A Data Sheet National Instruments Corporation C 5 PC DIO 24 User Manual...
Page 55: ...Appendix C OKI 82C55A Data Sheet PC DIO 24 User Manual C 6 National Instruments Corporation...
Page 56: ...Appendix C OKI 82C55A Data Sheet National Instruments Corporation C 7 PC DIO 24 User Manual...
Page 57: ...Appendix C OKI 82C55A Data Sheet PC DIO 24 User Manual C 8 National Instruments Corporation...
Page 58: ...Appendix C OKI 82C55A Data Sheet National Instruments Corporation C 9 PC DIO 24 User Manual...
Page 59: ...Appendix C OKI 82C55A Data Sheet PC DIO 24 User Manual C 10 National Instruments Corporation...
Page 60: ...Appendix C OKI 82C55A Data Sheet National Instruments Corporation C 11 PC DIO 24 User Manual...
Page 61: ...Appendix C OKI 82C55A Data Sheet PC DIO 24 User Manual C 12 National Instruments Corporation...
Page 62: ...Appendix C OKI 82C55A Data Sheet National Instruments Corporation C 13 PC DIO 24 User Manual...
Page 63: ...Appendix C OKI 82C55A Data Sheet PC DIO 24 User Manual C 14 National Instruments Corporation...
Page 64: ...Appendix C OKI 82C55A Data Sheet National Instruments Corporation C 15 PC DIO 24 User Manual...
Page 65: ...Appendix C OKI 82C55A Data Sheet PC DIO 24 User Manual C 16 National Instruments Corporation...
Page 66: ...Appendix C OKI 82C55A Data Sheet National Instruments Corporation C 17 PC DIO 24 User Manual...