Is it easy to reduce the clock frequency on Beaglebone I2C?

I want to stretch the I2C bus to a few metres, I will use screened
cable to minimise noise pick-up but this will increase the capacitive
load on the bus. So, I probably need to reduce the I2C clock
frequency, how easy is it to do this? I will probably use the
Adafruit libraries but don't have to.

The I2C protocol allows any slave device on the bus to ‘stretch’ the pulse for as long as it wants by holding SCL low (in Standard mode, and Fast mode, but not High-speed mode). This can slow the clock rate arbitrarily. It’s explained in specification:

I²C-bus Specification, Version 3.0 (Rev. 03 - 19 June 2007) this is the I2C reference!

You can do this fairly easily ‘bit twiddling’ a couple of IO pins on a microcontroller. It’s an interesting programming exercise!

Max

I want to stretch the I2C bus to a few metres, I will use screened
cable to minimise noise pick-up but this will increase the capacitive
load on the bus. So, I probably need to reduce the I2C clock
frequency, how easy is it to do this? I will probably use the
Adafruit libraries but don't have to.

The frequency is setup in the devicetree.

Regards,
John

You might like to have a look at the P82B96 data sheet.
Feature:
“400kHz operation over at least 20 meters of wire”

And you don’t have to modifiy your I2C code!

Martin H.

Just change the speed in board file or in dts

&i2c4 {
pinctrl-names = “default”;

clock-frequency = <400000>;

};

It is 400kHz you can change to 100kHz
or If you are using a board file

omap_register_i2c_bus(2, 400, drishti_i2c2_board_info,
ARRAY_SIZE(drishti_i2c2_board_info));

You can specify 100

I also dont see a point to reduce . You can also specify in u-boot as well

Kavitha

... and the P82B71 ...

Martin H.

Actually I have some P82B715PN on order, an older device but similar
and available in DIP so easier for me to use.

However it would still be nice to be able to slow the bus down rather
more easily than modifiying the device tree.

I freely admit that I don’t know anything about LINUX. We don’t use it.
But why would you want to modify the device tree if I2C is running?

We have I2C running with an LPC2468. All we did is putting a P8287 at each end of the line.
And it works. No code modification was required.

Martin H.

Well, say my BBB is also my local DNS server, or maybe it runs a print
server, or maybe someone else is using it to edit some files? If I
have to reboot it just to change the I2C frequency it will spoil all
those other things until it has rebooted.

Linux (like Unix) is a proper multitasking OS and while a BBB *might*
be dedicated to one task it is quite a powerful little beast and is
perfectly capable of doing all the things I've listed above at the
same time.

The whole philosophy of having to be root to do any significant
changes to the IO and of having to reboot as well is all wrong IMHO.

Hi Chris,
I did not mean to say that LINUX is not useful.
But yes, I can see your point: if you have to change the I2C clock that is something different.

Martin H.