<strong>ISA</strong> <strong>Servo</strong> <strong>Hardware</strong> <strong>Manual</strong>5.1.5 Register MIO.0-23 Digital I/O Mode Control Register 1This register is accessed from offset 0x06 in the high page for writes only.A. Mode Control CommandThe bit configuration shown here sets the general I/O mode. Other modes are available, butwould normally not be used for isolated I/O. For more information refer to the 82C55 data sheet.| 1 | 0 | 0 | A | CH | 0 | B | CL |where:A = For port A, B = For port B, CH = Upper 4 bits of port C, CL = Lower 4 bits of port C.writing a 1 = Input, and a 0 = OutputFor example, if the word: 10010001 were written to this address, then port A would be configured as aninput port, port B as an output port, the upper 4 bits of port C would be outputs, and the lower 4 bits ofport C would be inputs.B. Bit Set/Reset CommandThe following bit configuration, when written to this address, can be used to set individual bits inport C if those bits are configured as outputs.| 0 | 0 | 0 | 0 | B2 | B1 | B0 | Set |where:B2, B1, B0 = binary code of bit number in port C to modifySet = 1 to set or 0 to resetThis command may be used as a convenience to set bits in port C.Copyright 1995. 1996 <strong>Servo</strong> To Go, Inc. 16
<strong>Servo</strong> To Go, Inc.5.1.6 Register MIO.24-31 Digital I/O Mode Control Register 2This write-only register is at offset 0x07 in the high page. Similar to MIO.0-23, this register isused primarily to configure DIO.24-31 (Port D) as either 8 input bits or 8 output bits. Note: reading thisaddress will clear the odd numbered index pulse latch (see register ODDRST, section 5.1.8).A. Mode Control CommandWrite the byte, shown below, to set the direction of Port D. This byte actually sets the direction ofthree ports of an 82C55 IC. Besides Port D, the chip implements the BRDTST and INT.C registers.BRDTST is an input, which is the power-on default for the 82C55, so BRDTST works even before youwrite this byte. INT.C is an output, so you have to write this byte before INT.C will work.| 1 | 0 | 0 | D | 0 | 0 | 1 | 0 |where:D = Direction of DIO.24-31 (port D), 1 = Input, and 0 = Output.B. Bit Set/Reset CommandIndividual bits in the INT.C register (see section 5.1.9) can be set by writing the following byte tothis address.| 0 | 0 | 0 | 0 | B2 | B1 | B0 | Set |where:B2, B1, B0 = binary code of bit number in interrupt control port to modifySet = 1 to set or 0 to resetNote: An 82C55 is a parallel output IC with three 8-bit ports. This board uses two 82C55s. One of theseis used for Ports A, B and C (MIO.0-23); it is described in section 5.1.5. The second, described in thissection, is used for Port D (MIO.24-31), the INT.C register, and the BRDTST register. This 82C55 mustbe initialized before you use the INT.C register, therefore, the direction for port D must be set before youuse INT.C. If you change the direction of port D later, INT.C will be cleared -- instantly redirecting yourinterrupts. So, if you want to change the direction of Port D after you've set up INT.C and started usinginterrupts, you should mask interrupts and restore INT.C. Here is how to do it in C:bySaveIntc = _inp(wBaseAddress + INTC);bySaveIMR = _inp(wBaseAddress + IMR);_outp(wBaseAddress + OCW1, 0xff);_outp(wBaseAddress + MIO_2, 0x82);_outp(wBaseAddress + INTC, bySaveIntc);_outp(wBaseAddress + OCW1, bySaveIMR);// INTC needs to be saved, because// MIO_2 reinitializes the 8255 which// implements the INTC register.// get the current interrupt mask// mask off all interrupts// set port D to output// restore interrupt control reg.// restore interrupt mask17 Copyright 1995. 1996 <strong>Servo</strong> To Go, Inc.