Mode 0 Programming Example - National Instruments PC-DIO-24/PnP User Manual

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

Advertisement

Appendix C
Register-Level Programming
Control Word
Number
76543210
9
10010001
10
10010010
11
10010011
12
10011000
13
10011001
14
10011010
15
10011011
1
Upper nibble of port C
2
Lower nibble of port C
Main() {
#define BASE_ADDRESS
#define PORTAoffset
#define PORTBoffset
#define PORTCoffset
#define CNFGoffset
unsigned int porta, portb, portc, cnfg;
char valread;
/*
Calculate register addresses */
porta = BASE_ADDRESS + PORTAoffset;
portb = BASE_ADDRESS + PORTBoffset;
portc = BASE_ADDRESS + PORTCoffset;
cnfg
= BASE_ADDRESS + CNFGoffset;
/* EXAMPLE 1*/
outp(cnfg,0x80);
outp(porta,0x12);
outp(portb,0x34);
PC-DIO-24/PnP User Manual
Table C-3. Mode 0 I/O Configurations (Continued)
Bit
Port A
Input
Input
Input
Input
Input
Input
Input

Mode 0 Programming Example

The following example shows how to configure the 82C55A for various
combinations of mode 0 input and output. This code is strictly an
example and is not intended to be used without modification in a
practical situation.
0x180
0x00
0x01
0x02
0x03
/* Variable to store data read from a port */
/* Ports A, B, and C are outputs. */
/* Write data to port A. */
/* Write data to port B. */
Group A
1
Port C
Output
Output
Output
Input
Input
Input
Input
/* Board located at address 180 */
/* Offset for port A */
/* Offset for port B */
/* Offset for port C */
/* Offset for CNFG */
C-10
Group B
Port B
Port C
Output
Input
Input
Output
Input
Input
Output
Output
Output
Input
Input
Output
Input
Input
© National Instruments Corporation
2

Advertisement

Table of Contents
loading

Table of Contents