User’s Manual
19
Sample code for output bit 0~3 (using Turbo C/C++ 3.0):
outportb(0x2e,0x87); //Unlock
register
outportb(0x2e,0x87); //Unlock
register
outportb(0x2e,0x07); //Set Logic Device number pointer
outportb(0x2f,0x07);
//Set Logic Device number
outportb(0x2e,0xF2); //Set active register is CRF2
outportb(0x2f,0x00);
//Write data to digital output
3) Digital I/O control port (4E,4Fh):
Register configuration:
Bit
No
7 6 5 4 3 2 1 0
Map
IN7 IN6
OUT7
OUT6
OUT5
OUT4 IN5 IN4
Sample code for input bit 4~7(using Turbo C/C++ 3.0):
#define input_port 0x2f
outportb(0x4e,0x87); //Unlock
register
outportb(0x4e,0x87); //Unlock
register
outportb(0x4e,0x07); //Set Logic Device number pointer
outportb(0x4f,0x07);
//Set Logic Device number
outportb(0x4e,0xF1); //Set active register is CRF1
read_data=inportb(input_port); // Read digital input data
printf(“DIO-Input=%02X\n”,read_data); //Show digital input data on screen
Sample code for output bit 4~7(using Turbo C/C++ 3.0):
outportb(0x4e,0x87); //Unlock
register
outportb(0x4e,0x87); //Unlock
register
outportb(0x4e,0x07); //Set Logic Device number pointer
outportb(0x4f,0x07);
//Set Logic Device number
outportb(0x4e,0xF2); //Set active register is CRF2
outportb(0x4f,0x00);
//Write data to digital output