National Instruments PC-DIO-24/PnP User Manual page 81

24-bit digital i/o board for isa computers
Table of Contents

Advertisement

Main() {
#define BASE_ADDRESS
#define PORTAoffset
#define PORTBoffset
#define PORTCoffset
#define CNFGoffset
#define IREG1offset
#define IREG2offset
unsigned int porta, portb, portc, cnfg, ireg1, ireg2;
char valread;
/*
Calculate register addresses */
porta = BASE_ADDRESS + PORTAoffset;
portb = BASE_ADDRESS + PORTBoffset;
portc = BASE_ADDRESS + PORTCoffset;
cnfg
= BASE_ADDRESS + CNFGoffset;
ireg1 = BASE_ADDRESS + IREG1offset;
ireg2 = BASE_ADDRESS + IREG2offset;
/* EXAMPLE 1–Set up interrupts for mode 1 input for port A. Enable the
appropriate interrupt bits. */
outp(cnfg,0xB0);
outp(cnfg,0x09);
outp(ireg1,0x01);
outp(ireg2,0x04);
/* EXAMPLE 2–Set up interrupts for mode 1 input for port B. Enable the
appropriate interrupt bits. */
outp(cnfg,0x86);
outp(cnfg,0x05);
outp(ireg1,0x02);
outp(ireg2,0x04);
/* EXAMPLE 3–Set up interrupts for mode 1 output for port A. Enable the
appropriate interrupt bits. */
outp(cnfg,0xA0);
outp(cnfg,0x0D);
outp(ireg1,0x01);
outp(ireg2,0x04);
/* EXAMPLE 4–Set up interrupts for mode 1 output for port B. Enable the
outp(cnfg,0x84);
outp(cnfg,0x05);
© National Instruments Corporation
0x180
/* Board located at address 180 */
0x00
/* Offset for port A */
0x01
/* Offset for port B */
0x02
/* Offset for port C */
0x03
/* Offset for CNFG */
0x14
/* Offset for Interrupt Reg. 1 */
0x15
/* Offset for Interrupt Reg. 2 */
/* Variable to store data read from a port */
/* Port A is an input in mode 1. */
/* Set PC4 to enable interrupts from 82C55A. */
/* Set IRQ0 to enable port A interrupts. */
/* Set INTEN bit. */
/* Port B is an input in mode 1. */
/* Set PC2 to enable interrupts from 82C55A. */
/* Set IRQ1 to enable port B interrupts. */
/* Set INTEN bit. */
/* Port A is an output in mode 1. */
/* Set PC6 to enable interrupts from 82C55A. */
/* Set IRQ0 to enable port A interrupts. */
/* Set INTEN bit. */
appropriate interrupt bits. */
/* Port B is an output in mode 1. */
/* Set PC2 to enable interrupts from 82C55A. */
C-21
Appendix C
Register-Level Programming
PC-DIO-24/PnP User Manual

Advertisement

Table of Contents
loading

Table of Contents