Re: I2C on Raspberry Pi 4B has wrong clock rate?

From: Daniel O'Connor <darius_at_dons.net.au>
Date: Thu, 14 Nov 2024 08:05:24 UTC

> On 13 Nov 2024, at 14:27, Daniel O'Connor <darius@dons.net.au> wrote:
> I tried setting the frequency but it does not 'stick':
> [rpi13 3:56] ~ >sudo sysctl dev.iichb.0.frequency=10000
> dev.iichb.0.frequency: 100000 -> 100000

I tried lowering the clock frequency to 600MHz (from 1.5GHz) and it seems 100% reliable now..

I then tried increasing the clock divisor programmed in bcm_bsc_iicbus_reset by 3x and it works fine at 1.5GHz (and 600MHz).

I suppose in practise most users have devices which can run at 400kHz so running at 250kHz is no problem but the pijuice I2C is handled by a microcontroller so it is pickier.

Obviously fixing the code so it properly handles clock speeds changes would be good but I am not sure where to start with that.

The code uses IICBUS_GET_FREQUENCY() to find which rate to use for I2C - is there some tunable or hint that can set this? Or DTS?

Thanks.

--
Daniel O'Connor
"The nice thing about standards is that there
are so many of them to choose from."
-- Andrew Tanenbaum