Appendix D Register-Level Programming
©
National Instruments Corporation
D-13
PC-DIO-96/PnP User Manual
Mode 0 Programming Example
The following example shows how to configure PPI A 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.
Main() {
#define BASE_ADDRESS
0x180
/* Board located at address 180 */
#define APORTAoffset
0x00
/* Offset for PPI A, port A */
#define APORTBoffset
0x01
/* Offset for PPI A, port B */
#define APORTCoffset
0x02
/* Offset for PPI A, port C */
#define ACNFGoffset
0x03
/* Offset for PPI A, CNFG */
unsigned int porta, portb, portc, cnfg;
char valread;
/* Variable to store data read from a port */
/* Calculate register addresses */
porta = BASE_A APORTAoffset;
portb = BASE_A APORTBoffset;
portc = BASE_A APORTCoffset;
cnfg = BASE_A ACNFGoffset;
9
10010001
Input
Output
Output
Input
10
10010010
Input
Output
Input
Output
11
10010011
Input
Output
Input
Input
12
10011000
Input
Input
Output
Output
13
10011001
Input
Input
Output
Input
14
10011010
Input
Input
Input
Output
15
10011011
Input
Input
Input
Input
1
Upper nibble of port C
2
Lower nibble of port C
Table D-3. Mode 0 I/O Configurations (Continued)
Control Word
Group A
Group B
Number
Bit
76543210
Port A
Port C
1
Port B
Port C
2
Содержание PC-DIO-96/PnP
Страница 46: ......
Страница 47: ......
Страница 48: ......
Страница 49: ......
Страница 50: ......
Страница 51: ......
Страница 52: ......
Страница 53: ......
Страница 54: ......
Страница 55: ......
Страница 56: ......
Страница 57: ......
Страница 58: ......
Страница 59: ......
Страница 60: ......
Страница 61: ......
Страница 63: ......
Страница 64: ......
Страница 65: ......
Страница 66: ......
Страница 67: ......
Страница 68: ......
Страница 69: ......
Страница 70: ......
Страница 71: ......
Страница 72: ......
Страница 73: ......