I2C change SDA port direction

Technical questions regarding the XTC tools and programming with XMOS.
cicga
Active Member
Posts: 51
Joined: Tue Oct 11, 2011 4:48 pm

I2C change SDA port direction

Post by cicga »

Hi all,

protocol I2C need to change direction of SDA line from input to output for send ACK bit.

in XMOS example they just writing:

in one case - i2c.sda ;> Temp;
and in other case i2c.sda <: Temp;

but SDA port should be an input for get data and output for send ACK bit. :shock:

but I did not find how they change port direction on fly.

thanks

cicga


User avatar
Bianco
XCore Expert
Posts: 754
Joined: Thu Dec 10, 2009 6:56 pm

Post by Bianco »

An output operation followed by an input operation will automatically set the port to input.
The port has to be declared as a normal port (port portname) though.
cicga
Active Member
Posts: 51
Joined: Tue Oct 11, 2011 4:48 pm

Post by cicga »

Hi Bianco,

thanks for make it clear just how port should be declare - inp or out or does'nt matter?

could you pls point me where did you find this info?


best

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

Post by Ross »

Something like this?

Code: Select all

out port i2c_scl = XS1_PORT_1A;
port i2c_sda = XS1_PORT_1B;
User avatar
Bianco
XCore Expert
Posts: 754
Joined: Thu Dec 10, 2009 6:56 pm

Post by Bianco »

A port without a direction specified like for example the i2c_sda port in Ross' example is a bidirectional port and an output operation will set it to output and an input operation will set it to input.

Chapter 3.3 of the ports specification discusses this briefly (though without XC example).
cicga
Active Member
Posts: 51
Joined: Tue Oct 11, 2011 4:48 pm

Post by cicga »

thanks

its clear now

cicga