Page 1 of 1

Answer

Posted: Wed Sep 18, 2013 11:55 am
by sethu_jangala
No, you cannot use some bits of multi-bit port as input and some bits as output.


Can some bits of multi-bit port be used as input and some a

Posted: Wed Sep 18, 2013 11:55 am
by sethu_jangala
Trying to use 4-bit port as input and output simultaneously, Is it possible to select some bits of a 4-bit port as input and some bits as output? Does the architecture support for this configuration?


Answer 1824

Posted: Wed Sep 18, 2013 11:55 am
by Ross
No, but you can use peek() to return the values currently on the pins without turning the port into input mode.


Answer 2065

Posted: Thu Nov 21, 2013 12:07 pm
by infiniteimprobability
By design, a logical port has a single direction register, so all pins of that port have thier outputs enabled or not. However, there are options.

Firstly, most of the 8b ports are overlaid with 4b ports. For example 8B comes out on the same pins as 4C and 4D. So you can split that 8b port into two 4b ports, one set as input, one as output.
Secondly, you can do the tick of having inputs connect to the port via a series resistor. Normally the port is an output - the series resistor stops any contention. You can then turn the port around (doing an input does this) momentarily and read the port periodically. You need to wait a few cycles for the value to change (XMOS I/O is very fast) via the resistor, but then you can get the input value. Then you set it back to output (just do an output to enable the output drivers).
This of course only works if your outputs can tolerate a glitch - something like front panel LEDs won't mind..