Page 1 of 1

Bidirectional Port

Posted: Mon Sep 04, 2017 3:13 pm
by mehranpour
I have a basic question about Bidirectional GPIO on Multi bit ports.
I want to implement Bidirectional GPIO But it is not possible in multi-bit ports(?) According to I2c Application in multi-bit ports I want to check if I can use I2C structure. is there anyone who has any idea?

Thanks in advance.

Re: Bidirectional Port

Posted: Tue Sep 05, 2017 9:01 am
by johned
Hi mehranpour,
This functionality is different between XS-1 and xCORE-200.
Please see the documentation here : https://www.xmos.com/download/private/l ... rc3%29.pdf
Specifically :
Function i2c_master_single_port
Description Implements I2C on a single multi-bit port.
This function implements an I2C master bus using a single port. However, If this
function is used with an L-series or U-series xCORE device then reading from the
bus and clock stretching are not supported. The user needs to be aware that these
restriction are appropriate for the application. On xCORE-200 devices, reading and
clock stretching are supported.

Best,
John

Re: Bidirectional Port

Posted: Tue Sep 12, 2017 11:11 am
by Ross
I think there is some confusion here, I *think* the question is just can you do bidi on multiple-bit ports. The answer is yes, on any XMOS device:

port p = XS1_PORT_4A:

..

// Read from p into x
int x;
p :> x

// Write x back out to p
p <: x

(the I2C issue mentioned related to having SDA and SCL on one single multi-bit port and is related to drive mode restrictions on XS1)

Re: Bidirectional Port

Posted: Fri Mar 08, 2019 6:41 am
by MilanAP
Hi,
I have a bit different question on this topic. In my application on PORT_4C I have connected three outputs and one input from DC driver chip. It is possible to handle these three outputs and one input simultaneously? Just to have a better picture of what I am talking about , one of the output is PWM signal (which has to be driven continuously) and that one input is status signal (which I have to test periodically for possible error).

Or there is no way to do that this way and the input must be connected to other separate port?

Thanks.

BR,Milan

Re: Bidirectional Port

Posted: Fri Mar 08, 2019 9:34 pm
by akp
I don't know if you'll be able to do what you want to do. If you are using an XS2 then it might work to call set_port_drive_low() mode, which is an open drain output with a pull up. Then if you write '1' to the pin you want to use as an input, that pin will be weakly pulled up so your status signal might override it. If you execute an :> then it might work, I am not sure. Or it might turn the whole port to an input and turn off the set_port_drive_low() mode, I don't know. But if it does work your outputs would benefit from stronger external pull ups since when you write '1' to those pins they will only be weakly pulled up.

A better solution would be to take the status signal to a 1 bit port or a multi bit input port if you have no 1 bit ports available.

Re: Bidirectional Port

Posted: Tue Mar 12, 2019 8:54 pm
by MilanAP
Using this function really works on XS2 in my application, thanks for the advice.

Re: Bidirectional Port

Posted: Wed Mar 13, 2019 11:02 am
by akp
No problem, glad it worked.