Diamond Systems HELIX SINGLE BOARD COMPUTER Manual page 35

Pc/104 sbc with vortex processor and dual 10/100 ethernet switch
Hide thumbs Also See for HELIX SINGLE BOARD COMPUTER:
Table of Contents

Advertisement

Direction Control Register
The GPIO port 2 direction register at address 0x9A should always be set for all output mode by writing 0xFF to it.
This is the default setting, so no change should be required. Then the DIO port D/E direction control data can be
written to bits 1 and 0 of address 0x7A. Bit 1 controls the direction for port E, and bit 0 controls the direction for
port D. A 1 sets the port for output, and a 0 sets the port for input.
The data written to the direction control register should be confined to bits 1 and 0, because the other bits are
used for the serial port 1 and 2 protocol selection and should not be disturbed. The bits are set by first reading the
current register value, modifying the selected bit or bits, and then rewriting the data to the port. The example C
code below shows how to do this:
dir = inp(0x7A);
dir &= 0xFE;
dir |= 2;
outp(0x7A, dir);
Port Direction Registers
To set a port to output, first set the corresponding port 2 direction bit at address 0x7A to 1, then set the port 0
direction register 0x98 or port 1 direction register 0x99 to 0xFF.
To set a port to input, first set the port 0 direction register 0x98 or port 1 direction register 0x99 to 0x00, then set
the corresponding direction bit at port 2 / address 0x7A to 0.
The only valid values for the port 0/1 direction registers are FF and 00, since all bits in the port must be set to the
same direction due to the presence of the transceiver chip between the port and the I/O connector. The
sequences above are important to avoid conflicts with both the CPU chip and the transceiver chip driving their
connection simultaneously.
Port Data Registers
Once the direction registers for ports D and E are configured, the ports can be read or written as required at
addresses 0x78 and 0x79. Reading a port set for input mode will return the data on the corresponding I/O
connector pins. Writing a port in input mode will have no effect. Reading a port in output mode will return the
value last written into that port. Writing a port in output mode will send that data to the corresponding I/O
connector pins.
The example C code below shows how to configure and use ports D and E. In this code the example
configuration above is assumed to have already been executed, namely port D = input and port E = output.
outp(0x98, 0);
outp(0x99, 0xFF);
ddata = inp(0x78);
edata = 0x12;
outp(0x79, edata);
Helix User Manual Rev A
// read current port 2 register data
// example, clear bit 0 to configure port D as input
// example, set bit 1 to configure port E as output
// write new data to port 2 register
// set port D to input
// set port E to output
// read data from port D
// set port E to 00010010
// write new data to port E
www.diamondsystems.com
Page 35

Advertisement

Table of Contents
loading

Table of Contents