![background image](http://html1.mh-extra.com/html/national-instruments/daqcard-dio-24/daqcard-dio-24_user-manual_709163064.webp)
Appendix B
Register-Level Programming
©
National Instruments Corporation
B-23
DAQCard-DIO-24 User Manual
/* Else if PC = 1, set base address and define rd and wrt. */
#elif
PC
#define
BASE_ADDRESS
0x0220
#define
rd(a)
((unsigned char) inp(((unsigned int) (a))))
#define
wrt(a,d)
(outp(((unsigned int) (a)), ((unsigned char) (d))))
#end
#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 long 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. */
wrt(cnfg,0xB0);
/* Port A is an input in mode 1. */
wrt(ireg1,0x01);
/* Set IRQ0 to enable port A interrupts. */
wrt(cnfg,0x09);
/* Set PC4 to enable interrupts from */
/* 82C55A. */
wrt(ireg2,0x04);
/* Set INTEN bit. */
/* EXAMPLE 2–Set up interrupts for mode 1 input for port B. Enable the
appropriate interrupt bits. */
wrt(cnfg,0x86);
/* Port B is an input in mode 1. */
wrt(ireg1,0x02);
/* Set IRQ1 to enable port B interrupts.*/
wrt(cnfg,0x05);
/* Set PC2 to enable interrupts from */
/* 82C55A. */
wrt(ireg2,0x04);
/* Set INTEN bit. */