User`s manual
ENDAT-2794A USERS MANUAL
UNICORN COMPUTER CORP.
21
DIGITAL I/O Pin (DIO-I3:DIO-I0) Register configuration (register number: E2):
bit No 7 6 5 4 3 2 1 0
Map NA NA NA NA DIO-I3 DIO-I2 DIO-I1 DIO-I0
Sample code for input (using Turbo C/C++ 3.0)
DIGITAL I/O Pin (DIO-O1:DIO-O0) Register configuration (register number: E1):
bit No 7 6 5 4 3 2 1 0
Map DIO-O1 NA NA DIO-O0 NA NA NA NA
Sample code for output (using Turbo C/C++ 3.0)
DIGITAL I/O Pin (DIO-O2) Register configuration (register number: F1):
bit No 7 6 5 4 3 2 1 0
Map DIO-O2 NA NA NA NA NA NA NA
Sample code for output (using Turbo C/C++ 3.0)
#define input_port 0x4f // Digital input data port
Unsigned char read_data;
outportb(0x4e,0x87); //Unlock register
outportb(0x4e,0x87); //Unlock register
outportb(0x4e,0x07); //Set Logic Device number pointer
outportb(0x4f,0x06); //Set Logic Device number.
outportb(0x4e,0xE2); //Set active register is CRE2
read_data=inportb(input_port); // Read digital input data
read_data=read_data&&0x0f; //Get bit3~0
printf("DIO-Input=%x\n",read_data); //Show digital input data on screen
outportb(0x4e,0x87); //Unlock register
outportb(0x4e,0x87); //Unlock register
outportb(0x4e,0x07); //Set Logic Device number pointer
outportb(0x4f,0x06); //Set Logic Device number.
outportb(0x4e,0xE1); //Set active register is CRE1
outportb(0x4f,0x10); // Set bit4 (DIO-O0) as logical high
outportb(0x4f,0x80); //Set bit7 (DIO-O1) as logical high
outportb(0x4e,0x87); //Unlock register
outportb(0x4e,0x87); //Unlock register
outportb(0x4e,0x07); //Set Logic Device number pointer
outportb(0x4f,0x06); //Set Logic Device number.
outportb(0x4e,0xF1); //Set active register is CRF1
outportb(0x4f,0x80); //Set bit7 (DIO-O2) as logical high