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

If you have a simple question and just want an answer.
Post Reply
User avatar
sethu_jangala
XCore Expert
Posts: 589
Joined: Wed Feb 29, 2012 10:03 am

Post by sethu_jangala »

No, you cannot use some bits of multi-bit port as input and some bits as output.



View Solution
User avatar
sethu_jangala
XCore Expert
Posts: 589
Joined: Wed Feb 29, 2012 10:03 am

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

Post 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?

User avatar
Ross
XCore Expert
Posts: 962
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

Post by Ross »

No, but you can use peek() to return the values currently on the pins without turning the port into input mode.

User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am
Contact:

Post 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..

 

Post Reply