Hi Folks,
I’m working with an I2C LCD rated for up to 50KHz and it is showing a fair number of glitches. Can anyone tell me how to lower the I2C speed from the default values, which I understand to be 100KHz, minimum.

I tried the I2C_SPEED_SET() macro, which threw a warning and I tried a few speed settings in the overlay file but I don’t know if any of that worked. Does anyone know the proper way to do this?

Thanks,
Jim

Hey Jim

Typically you can use the clock-frequency entry for that particular bus:

&i2c1 {
	compatible = "nordic,nrf-twim";
	status = "okay";

	clock-frequency = <I2C_BITRATE_FAST>;
	pinctrl-0 = <&i2c1_default>;
	pinctrl-1 = <&i2c1_sleep>;
	pinctrl-names = "default", "sleep";

There are some pre-defined values in i2c.h:

#define I2C_BITRATE_STANDARD	100000	/* 100 Kbit/s */
#define I2C_BITRATE_FAST	400000	/* 400 Kbit/s */

You should be able to indicate the rate if there’s no macro for it:

clock-frequency = <250000>;

If you’re using the nRF9160, it only supports 100, 250, and 400 kbps. If you’re getting glitches I recommend changing or adding external pull-ups to the I2C interface. The nRF9160 Feather has 20K pullups which isn’t sufficient in some cases. (depends on the capacitive loading of I2C signals by all sensors and devices on the bus)

Thanks you Jared - I’ll try the speed directive. Great insight on the pull-up resistors - I’ll see what I can do there if the glitches continue.

Best,
Jim

You got it! My recommendation would be to reduce to 10k on both lines and check if you’re still having issues. Having an oscilloscope to check would very handy here.

Terms and Conditions | Privacy Policy