Register-Level Programming
Chapter 4
PC-DIO-24 User Manual
4-14
© National Instruments Corporation
/* EXAMPLE 1*/
outp(cnfg,0xC0);
/* Port A is in mode 2. */
while (!(inp(portc) & 0x80));
/* Wait until OBFA* is set,
indicating that the data last
written to port A has been
read.*/
outp(porta,0x67);
/* Write the data to port A. */
while (!(inp(portc) & 0x20));
/* Wait until IBFA is set, indicating
that data is available in port A to
be read. */
valread = inp(porta);
/* Read data from port A. */
}
Interrupt Programming Examples
The following examples show the process required to enable interrupts for several different
operating modes. The interrupt handling routines and interrupt installation routines are not
included. See the IBM Personal Computer AT Technical Reference manual for additional
information.
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–Set up interrupts for mode 1 input for port A. Select PC6 as the
interrupt enable bit. */
outp(cnfg,0xB0);
/* Port A is an input in mode 1. */
outp(cnfg,0x09);
/* Set PC4 to enable interrupts from
82C55A. */
outp(cnfg,0x0C);
/* Clear PC6 to enable interrupts. */
/* EXAMPLE 2–Set up interrupts for mode 1 input for port B. Select PC6 as the
interrupt enable bit. */
outp(cnfg,0x86);
/* Port B is an input in mode 1. */
outp(cnfg,0x05);
/* Set PC2 to enable interrupts from
82C55A. */
outp(cnfg,0x0C);
/* Clear PC6 to enable interrupts. */
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...