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
I2C change SDA port direction
-
- Active Member
- Posts: 51
- Joined: Tue Oct 11, 2011 4:48 pm
-
- XCore Expert
- Posts: 754
- Joined: Thu Dec 10, 2009 6:56 pm
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.
The port has to be declared as a normal port (port portname) though.
-
- Active Member
- Posts: 51
- Joined: Tue Oct 11, 2011 4:48 pm
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
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
-
- XCore Expert
- Posts: 968
- Joined: Thu Dec 10, 2009 9:20 pm
- Location: Bristol, UK
Something like this?
Code: Select all
out port i2c_scl = XS1_PORT_1A;
port i2c_sda = XS1_PORT_1B;
-
- XCore Expert
- Posts: 754
- Joined: Thu Dec 10, 2009 6:56 pm
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).
Chapter 3.3 of the ports specification discusses this briefly (though without XC example).
-
- Active Member
- Posts: 51
- Joined: Tue Oct 11, 2011 4:48 pm
thanks
its clear now
cicga
its clear now
cicga