![background image](http://html1.mh-extra.com/html/national-instruments/daqcard-dio-24/daqcard-dio-24_user-manual_709163059.webp)
Appendix B
Register-Level Programming
DAQCard-DIO-24 User Manual
B-18
©
National Instruments Corporation
#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 */
#define IREG1offset
0x14
/* Offset for Interrupt Reg. 1*/
unsigned long porta, portb, portc, cnfg, ireg1;
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;
ireg1 = BASE_A IREG1offset;
/* EXAMPLE 1–Port A output */
wrt(cnfg,0xA0);
/* Port A is an output in mode 1.*/
while (!(rd(portc) & 0x80))
/* Wait until OBFA* is set, indicating */
rd(ireg1);
/* that the data last written to port A*/
/* has been read. */
wrt(porta,0x12);
/* Write data to port A. */
/* EXAMPLE 2–Port B output */
wrt(cnfg,0x84);
/* Port B is an output in mode 1.*/
while (!(rd(portc) & 0x02))
/* Wait until OBFB* is set, indicating */
rd(ireg1);
/* that the data last written to port B */
/* has been read. */
wrt(portb,0x34);
/* Write the data to port B. */
}
Mode 2 Bidirectional Bus
Mode 2 has an 8-bit bus that can transfer both input and output 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 PC<2..0> of port C can be used as extra
input or output lines.
Содержание DAQCard-DIO-24
Страница 68: ...Appendix C OKI 82C55A Data Sheet DAQCard DIO 24 User Manual C 2 National Instruments Corporation ...
Страница 69: ...Appendix C OKI 82C55A Data Sheet National Instruments Corporation C 3 DAQCard DIO 24 User Manual ...
Страница 70: ...Appendix C OKI 82C55A Data Sheet DAQCard DIO 24 User Manual C 4 National Instruments Corporation ...
Страница 71: ...Appendix C OKI 82C55A Data Sheet National Instruments Corporation C 5 DAQCard DIO 24 User Manual ...
Страница 72: ...Appendix C OKI 82C55A Data Sheet DAQCard DIO 24 User Manual C 6 National Instruments Corporation ...
Страница 73: ...Appendix C OKI 82C55A Data Sheet National Instruments Corporation C 7 DAQCard DIO 24 User Manual ...
Страница 74: ...Appendix C OKI 82C55A Data Sheet DAQCard DIO 24 User Manual C 8 National Instruments Corporation ...
Страница 75: ...Appendix C OKI 82C55A Data Sheet National Instruments Corporation C 9 DAQCard DIO 24 User Manual ...
Страница 76: ...Appendix C OKI 82C55A Data Sheet DAQCard DIO 24 User Manual C 10 National Instruments Corporation ...
Страница 77: ...Appendix C OKI 82C55A Data Sheet National Instruments Corporation C 11 DAQCard DIO 24 User Manual ...
Страница 78: ...Appendix C OKI 82C55A Data Sheet DAQCard DIO 24 User Manual C 12 National Instruments Corporation ...
Страница 79: ...Appendix C OKI 82C55A Data Sheet National Instruments Corporation C 13 DAQCard DIO 24 User Manual ...
Страница 80: ...Appendix C OKI 82C55A Data Sheet DAQCard DIO 24 User Manual C 14 National Instruments Corporation ...
Страница 81: ...Appendix C OKI 82C55A Data Sheet National Instruments Corporation C 15 DAQCard DIO 24 User Manual ...
Страница 82: ...Appendix C OKI 82C55A Data Sheet DAQCard DIO 24 User Manual C 16 National Instruments Corporation ...
Страница 83: ...Appendix C OKI 82C55A Data Sheet National Instruments Corporation C 17 DAQCard DIO 24 User Manual ...