I2C Timing Issues Topic is solved

Technical questions regarding the XTC tools and programming with XMOS.
Post Reply
ChrisDev
Member
Posts: 13
Joined: Tue Jan 31, 2017 8:45 am

I2C Timing Issues

Post by ChrisDev »

Hello everybody,

I'm currently having some issues using an I2C communication or rather using the i2c library.
It seems to have no effect if, the kbits per second parameter is changed.
-- i2c_lib - snippet

Code: Select all

/** Implements I2C on the i2c_master_if interface using two ports.
 *
 *  \param  i      An array of server interface connections for clients to
 *                 connect to
 *  \param  n      The number of clients connected
 *  \param  p_scl  The SCL port of the I2C bus
 *  \param  p_sda  The SDA port of the I2C bus
 *  \param  kbits_per_second The speed of the I2C bus
 **/
[[distributable]] void i2c_master(server interface i2c_master_if i[n],
                                  size_t n,
                                  port p_scl, port p_sda,
                                  unsigned kbits_per_second);

main.xc - snippet

Code: Select all

par{
    on tile[1]:i2c_master(i2c,1,SCL,SDA,100);
    on tile[1]:adc(i2c,0);
}
By using these configuration for the i2c the result is like this:
Image
SCL in blue, SDA in yellow. On the right hand side the timing is measured with two coursers.

Rising or lowering this parameter doesn't really effect the timing. Also the SCL's shape seems to be a bit suspicious.

Is this a known problem ? I haven't modified the i2c_lib in any kind.


Edit:
I was digging a bit more regarding this problem and found out that the variable 'bit_time' which is calculated in the i2c_master task always has the value 100. No matter if kbits_per_second is about 100, 400 or even 1000.
But when I was trying to debug the calculation the xtimecomposer showed in the variable tab the following error... "_Si2c_master_0.init.1.state_ptr <mi_cmd_var_create: unable to create variable object>"


Cheers,
Chris


View Solution
User avatar
mon2
XCore Legend
Posts: 1913
Joined: Thu Jun 10, 2010 11:43 am
Contact:

Post by mon2 »

Hi.

1) A bit of dialog of your error posted here:

https://www.eclipse.org/forums/index.php/t/245570/

http://www.xcore.com/viewtopic.php?t=1585

2) Forget the bit rate calculator and spoon feed the proper values manually - does that work to alter the SCL / SDA speeds ?

So change line 109 to a static value and test again. XS1_TIMER_MHZ should be 100.

From the scope capture, SCL is around 860khz ? If yes, that is beyond spec for most parts.

3) On the waveforms, what is the value of the I2C pull-ups for your project ? Recommend the values be 2.2k - 2.7k to 3v3. XMOS is not 5 volt tolerant on the port pins. We have found the pull-up resistors values are really not so critical but use 2k2 or higher and review the length of your I2C traces / wiring and suggest to keep them as short as possible.

Post back if this does not get resolved.
Post Reply