Knowledge Base

When you use the SPiceX transfer method you need to know which physical I/O bits on the expansion board(s) correspond to (map to) which bytes and bits within the U register.

The XPice expansion boards are built around 8 bit shift registers. These shift registers are always used in pairs. One of the pair provides 8 output bits and one provides 8 input bits. On 8 in/ 8 out boards like the XIRO16 there is just one such pair. The XBIO16 on the other hand has 2 pairs, giving 16 inputs and 16 outputs. However, the inputs and outputs are connected together on the board to yield 16 bidirectional I/O pins, saving on connectors, indicator LEDS and board space. When you connect several boards together you are actually connecting their shift registers together into two long chains.

When you execute a SPxTxfrU instruction, data gets shifted out of U into the output shift registers, at the same time as data is shifted from the input shift registers into U. The direction of shifting is out of U0, bit 0, and in to Un-1, bit 7 (n= the number of bytes involved). When the shifting is finished, the data that was in U0 will be in the output shift register that is electrically furthest from the controller. At the same time the new data in U0 will be the input data from the input shift register that is electrically closest to the controller. That means the input and output data are in reverse byte order relative to each other. Note however that the bit order within each byte is always the same, i.e. not reversed.

The following table shows the mapping for four XBIO16 boards. Each XBIO16 board has 16 bits, each of which can be used as an input or as an output. These are numbered 0-7 for the first byte’s worth, and 8-15 for the second byte’s worth. The table shows for each of the 4 boards where the data associated with each byte will end up in U if it’s used as an input, or where in U it will originate from if used as an output. Board 1 is the board electrically closest to the controller, i.e the one whose SPxIn connector is connected to the controller.

XBIO16Board 1Board 2Board 3Board 4
0-78-150-78-150-78-150-78-15
InputsU0U1U2U3U4U5U6U7
OutputsU7U6U5U4U3U2U1U0

The next table show the situation for three XBIO16 boards. Because of the byte order reversal, and because U0 must always be represented, this table is not just the previous table with the board 4 data chopped off.

XBIO16Board 1Board 2Board 3
0-78-150-78-150-78-15
InputsU0U1U2U3U4U5
OutputsU5U4U3U2U1U0

You should study these tables until you can clearly see the pattern.

The next table shows the situation for a system with six XIRO16 boards. It is remarkable similar to the case of three XBIO16 boards.

XIRO16Brd1Brd2Brd3Brd4Brd5Brd6
InputsU0U1U2U3U4U5
OutputsU5U4U3U2U1U0

From the above you should be able to work out the mapping for your particular setup, including a mixture of board types.