Instructions for changing the clock frequency of the I2C bus as I did not find it else where when figuring out how to do it.
The default clock frequency of I2C is 100kHz, to change to another frequency (400kHz, 1MHz etc) you need to create an overlay for the I2C bus you want modified.
In my configuration I use rsetup
to enable I2C0-M1 on GPIO pins 28 (SCL) and 27 (SDA).
To change the clock frequency to 400kHz create a file name i2c0-400khz.dts
with contents;
/dts-v1/;
/plugin/;
/ {
metadata {
title = "Set I2C0-M1 to 400khz";
category = "misc";
compatible = "radxa,rock-5b", "rockchip,rk3588";
description = "Set I2C0-M1 to 400khz";
};
fragment@0 {
target = <&i2c0>;
__overlay__ {
clock-frequency = <400000>; // Set to 400 kHz
};
};
};
Then load rsetup
and select menu option Overlay->Install 3rd party overlay
and select the file we created. This will then install our overlay.
Exit rsetup and reboot for the change to take effect.
If your running I2C on a different GPIO configuration, then modify the target = <&i2c0>;
parameter in the above overlay file and set it appropriately to the bus you want changed.