Mode 1 Input Programming Example; Mode 1-Strobed Output - National Instruments PC-DIO-24 User Manual

Digital i/o board for the ibm pc/xt/at
Table of Contents

Advertisement

Chapter 4

Mode 1 Input Programming Example

Main() {
#define BASE_ADDRESS
#define PORTAoffset
#define PORTBoffset
#define PORTCoffset
#define CNFGoffset
register 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–port A input */
outp(cnfg,0xB0);
while (!(inp(portc) & 0x20));
valread = inp(porta);
/* EXAMPLE 2–port B input */
outp(cnfg,0x86);
while (!(inp(portc) & 0x02));
valread = inp(portb);
}
Mode 1–Strobed Output
The control word written to the CNFG Register to configure port A for output in mode 1 is
shown as follows. Bits PC4 and PC5 of port C can be used as extra input or output lines when
port A uses mode 1 output.
7
1
© National Instruments Corporation
0x210
/* Board located at address 210. */
0x00
/* Offset for port A */
0x01
/* Offset for port B */
0x02
/* Offset for port C */
0x03
/* Offset for CNFG
/* Variable to store data read from a
/* Port A is an input in mode 1. */
/* Wait until IBFA is set, indicating that
/* Read the data from port A. */
/* Port B is an input in mode 1. */
/* Wait until IBFB is set, indicating that
6
5
4
3
0
1
0
1/0
4-9
port */
data has been loaded in port A. */
data has been loaded in port B. */
2
1
0
X
X
X
Port C bits PC4 and PC5
1 = input
0 = output
Register-Level Programming
*/
PC-DIO-24 User Manual

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents