Appendix C
Register-Level Programming
©
National Instruments Corporation
C-21
PC-DIO-24/PnP User Manual
Main() {
#define BASE_ADDRESS
0x180
/* Board located at address 180 */
#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 */
#define IREG2offset
0x15
/* Offset for Interrupt Reg. 2 */
unsigned int porta, portb, portc, cnfg, ireg1, ireg2;
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;
ireg2 = BASE_A IREG2offset;
/* EXAMPLE 1–Set up interrupts for mode 1 input for port A. Enable the
appropriate interrupt bits. */
outp(cnfg,0xB0);
/* Port A is an input in mode 1. */
outp(cnfg,0x09);
/* Set PC4 to enable interrupts from 82C55A. */
outp(ireg1,0x01);
/* Set IRQ0 to enable port A interrupts. */
outp(ireg2,0x04);
/* Set INTEN bit. */
/* EXAMPLE 2–Set up interrupts for mode 1 input for port B. Enable the
appropriate interrupt bits. */
outp(cnfg,0x86);
/* Port B is an input in mode 1. */
outp(cnfg,0x05);
/* Set PC2 to enable interrupts from 82C55A. */
outp(ireg1,0x02);
/* Set IRQ1 to enable port B interrupts. */
outp(ireg2,0x04);
/* Set INTEN bit. */
/* EXAMPLE 3–Set up interrupts for mode 1 output for port A. Enable the
appropriate interrupt bits. */
outp(cnfg,0xA0);
/* Port A is an output in mode 1. */
outp(cnfg,0x0D);
/* Set PC6 to enable interrupts from 82C55A. */
outp(ireg1,0x01);
/* Set IRQ0 to enable port A interrupts. */
outp(ireg2,0x04);
/* Set INTEN bit. */
/* EXAMPLE 4–Set up interrupts for mode 1 output for port B. Enable the
appropriate interrupt bits. */
outp(cnfg,0x84);
/* Port B is an output in mode 1. */
outp(cnfg,0x05);
/* Set PC2 to enable interrupts from 82C55A. */
Содержание PC-DIO-24/PnP
Страница 45: ...Appendix B OKI 82C55A Data Sheet PC DIO 24 PnP User Manual B 2 National Instruments Corporation ...
Страница 46: ...Appendix B OKI 82C55A Data Sheet National Instruments Corporation B 3 PC DIO 24 PnP User Manual ...
Страница 47: ...Appendix B OKI 82C55A Data Sheet PC DIO 24 PnP User Manual B 4 National Instruments Corporation ...
Страница 48: ...Appendix B OKI 82C55A Data Sheet National Instruments Corporation B 5 PC DIO 24 PnP User Manual ...
Страница 49: ...Appendix B OKI 82C55A Data Sheet PC DIO 24 PnP User Manual B 6 National Instruments Corporation ...
Страница 50: ...Appendix B OKI 82C55A Data Sheet National Instruments Corporation B 7 PC DIO 24 PnP User Manual ...
Страница 51: ...Appendix B OKI 82C55A Data Sheet PC DIO 24 PnP User Manual B 8 National Instruments Corporation ...
Страница 52: ...Appendix B OKI 82C55A Data Sheet National Instruments Corporation B 9 PC DIO 24 PnP User Manual ...
Страница 53: ...Appendix B OKI 82C55A Data Sheet PC DIO 24 PnP User Manual B 10 National Instruments Corporation ...
Страница 54: ...Appendix B OKI 82C55A Data Sheet National Instruments Corporation B 11 PC DIO 24 PnP User Manual ...
Страница 55: ...Appendix B OKI 82C55A Data Sheet PC DIO 24 PnP User Manual B 12 National Instruments Corporation ...
Страница 56: ...Appendix B OKI 82C55A Data Sheet National Instruments Corporation B 13 PC DIO 24 PnP User Manual ...
Страница 57: ...Appendix B OKI 82C55A Data Sheet PC DIO 24 PnP User Manual B 14 National Instruments Corporation ...
Страница 58: ...Appendix B OKI 82C55A Data Sheet National Instruments Corporation B 15 PC DIO 24 PnP User Manual ...
Страница 59: ...Appendix B OKI 82C55A Data Sheet PC DIO 24 PnP User Manual B 16 National Instruments Corporation ...
Страница 60: ...Appendix B OKI 82C55A Data Sheet National Instruments Corporation B 17 PC DIO 24 PnP User Manual ...