Bidirectional Port

Sub forums for various specialist XMOS applications. e.g. USB audio, motor control and robotics.
Posts: 1
Joined: Mon Sep 04, 2017 2:45 pm

Bidirectional Port

Postby mehranpour » Mon Sep 04, 2017 3:13 pm

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.
User avatar
XCore Addict
Posts: 166
Joined: Tue Mar 26, 2013 12:10 pm

Postby johned » Tue Sep 05, 2017 9:01 am

Hi mehranpour,
This functionality is different between XS-1 and xCORE-200.
Please see the documentation here : ... 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.

User avatar
XCore Expert
Posts: 768
Joined: Thu Dec 10, 2009 9:20 pm

Postby Ross » Tue Sep 12, 2017 11:11 am

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)
New User
Posts: 2
Joined: Thu Feb 28, 2019 7:40 am

Postby MilanAP » Fri Mar 08, 2019 6:41 am

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?


User avatar
Respected Member
Posts: 302
Joined: Thu Nov 26, 2015 11:47 pm

Postby akp » Fri Mar 08, 2019 9:34 pm

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.
New User
Posts: 2
Joined: Thu Feb 28, 2019 7:40 am

Postby MilanAP » Tue Mar 12, 2019 8:54 pm

Using this function really works on XS2 in my application, thanks for the advice.
User avatar
Respected Member
Posts: 302
Joined: Thu Nov 26, 2015 11:47 pm

Postby akp » Wed Mar 13, 2019 11:02 am

No problem, glad it worked.

Who is online

Users browsing this forum: No registered users and 0 guests