Bidirectional Port

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

Bidirectional Port

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


User avatar
johned
XCore Addict
Posts: 185
Joined: Tue Mar 26, 2013 12:10 pm
Contact:

Post 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
User avatar
Ross
XCore Expert
Posts: 962
Joined: Thu Dec 10, 2009 9:20 pm
Location: Bristol, UK

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

Post 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
User avatar
akp
XCore Expert
Posts: 578
Joined: Thu Nov 26, 2015 11:47 pm

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

Post by MilanAP »

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

Post by akp »

No problem, glad it worked.
Post Reply