PIO/PEX-D24/D56 Series User Manual (Ver.3.1, Mar. 2015, PMH-005-31)
34
3.3.9 Read/Write 8-bit data Register
(Read/Write):wBase+0xc0/0xc4/0xc8/0xd0/0xd4
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
D7
D6
D5
D4
D3
D2
D1
D0
The PIO-D24/D56 and PEX-D24/D56 series contains 5/3 8-bit I/O ports, and
each I/O port can be configured as either a D/I or a D/O port. The user can
send/receive digital data to/from this register for digital input or output. Note that
all ports are set as D/I ports when the PC is first powered-on.
outportb(wBase+0xc0,Val);
/*Write to port-0 */
Val=inportb(wBase+0xc0);
/*Read from port-0*/
outportb(wBase+0xcc,0x07);
/*Set Port0~Port2 as DO port */
outportb(wBase+0xc0,i1);
/*Write to Port0 */
outportb(wBase+0xc4,i2);
/*Write to Port1 */
outportb(wBase+0xc8,i3);
/*Write to Port2 */
outportb(wBase+0xcc,0x01);
/*Set Port0 as DO port */
/*port1~Port2 as DI port */
outportb(wBase+0xc0,i1);
/*Write to Port0 */
j2=inportb(wBase+0xc4);
/*Read Port1 */
j3=inportb(wBase+0xc8);
/*Read Port2 */
L=inportb(wBase+0xd0);
/*Read CON2 Low byte */
H=inportb(wBase+0xd4);
/*Read CON2 High byte */
Val=(H<<8)+L ;
/*Val is 16 bit data */
outportb(wBase+0xd0,Val);
/*Write to CON1 Low byte */
outportb(wBase+0xd4,(Val>>8));
/*Write to CON1 high byte */
Note: Make sure the I/O port configuration (DI or DO) before read/write
the data register (wBase+0xc0/0xc4/0xc8), refer to Sec.3.3.7 and Table
3.3 for more information.
!