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 Topic is solved
-
- XCore Expert
- Posts: 589
- Joined: Wed Feb 29, 2012 10:03 am
-
- 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
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?
-
Verified
- XCore Legend
- Posts: 1163
- Joined: Thu Dec 10, 2009 9:20 pm
- Location: Bristol, UK
No, but you can use peek() to return the values currently on the pins without turning the port into input mode.
Technical Director @ XMOS. Opinions expressed are my own
-
Verified
- XCore Legend
- Posts: 1156
- Joined: Thu May 27, 2010 10:08 am
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..
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..
Engineer at XMOS