
Control Programming
•
27
To initial I/O port
# define INDEX 0x300
//define same as
//address setting
# define DATA 0x301
//data R/W port
# define CW0 0x3
//port 0 control port
# define CW1 0x7
//port 1 control port
# define CWD0 0x0A
//0AH refer to 8255 CW
//Mode6 Port A & B output,
// Port C input
# define CWD1 0x0B
//0BH refer to 8255 CW
//Mode7 Port A output,
// Port B & C input
outportb( INDEX,CW0);
//point to port0's control word
outportb( DATA,CWD0);
//initial port0
outportb( INDEX,CW1);
//point to port1's control word
outportb( DATA,CWD1);
//initial port 1
To write port
# define INDEX 0x300
//INDEX same as SW
//setting
# define DATA 0x301
//data R/W port
# define CW1 0x3
//port 0 CW
# define MOD0 0x0
//8255 mode 0 Port A, B & C
// are output port
#define PA0 0x0 //port A0
#define PB0 0x1 //port B0
outportb(INDEX,CW0);
//index to port0 CW
outportb(DATA,MOD0);
//initial port0 as
//mod 0 for output
outportb(INDEX,PA0);
//index to port A0
outportb(DATA,0x55);
//output 55H
outportb(INDEX,PB0);
//index to port B0
outportb(DATA, 0xFF); //output FFH to Port B0
To access port
# define INDEX 0x300
//INDEX same as SW
//setting
# define DATA 0x301
//data R/W port
# define MOD15 0x17
//8255 mode 15
# define PA1 0x4 //PA1 port index
# define CW1 0x7//port 1 CW
int input;
//input data buffer
outportb(INDEX,CW1);
//index to port 1 CW
Содержание PET-48DIO
Страница 1: ...NuDAQ PET 48DIO Programmable 48 bit DIO Event and Timer Cards User s Guide...
Страница 2: ......