4

The raspberry pi 3 B has a fixed i2c speed of 100kHz because of productions errors. I assumed that they have fixed it in the new version Raspberry pi 4, but of course there have been newer standards since then too of speed reaching up to the MHz range. Given the previous errors, it would make me doubt what the software is saying that it is running on

Does anyone know what is the maximum speed the pi 4 can handle, it would be better if you have actually scoped the lines yourself. I unfortunately dont have easy access to a scope and am pretty much blind.

tlfong01
  • 4,847
  • 3
  • 12
  • 24
Jack
  • 714
  • 3
  • 8
  • 19

4 Answers4

8

As a side note to anyone experimenting with the i2c baudrate, you don't have to set the baudrate via config.txt, which requires a reboot. You can do it at runtime by configuring the kernel module with modprobe:

sudo rmmod i2c_bcm2708
sudo modprobe i2c_bcm2708 baudrate=400000

Also bear in mind that Pi does not support clock stretching on I2C, so I2C devices which rely on this feature will not work at their specified maximum clock rate. Setting the clock frequency to a smaller value usually helps.

Dmitry Grigoryev
  • 28,277
  • 6
  • 54
  • 147
6

Answer

I have confirmed that Rpi4B 4GB v1.2 buster 2020feb13 I2C #1 can set speed other than 100kHz.

Figures

i2c 1


i2c 2


i2c 3


io2c 4


i2c 5


i2c 6


i2c 7


Appendices

Appendix A - /boot/config.txt tlfong01 2020mar04

# /boot/config.txt 2020feb0801  tlfong01  2020feb08hkt1701
# last update 2020feb13hkt2238
# last update 2020mar02hkt1521 
# last update 2020mar04hkt1830

# *** Display ***

disable_overscan=1
dtoverlay=vc4-fkms-v3d
max_framebuffers=2

# *** Audio ***

dtparam=audio=on

# *** UART ***

enable_uart=1

# *** I2C ***

# dtparam=i2c_arm=on,i2c_arm_baudrate=50000
#dtparam=i2c_arm=on,i2c_arm_baudrate=100000
#dtparam=i2c_arm=on,i2c_arm_baudrate=400000
dtparam=i2c_arm=on,i2c_arm_baudrate=1000000

dtoverlay=i2c1,pins_2_3   (board pins  3,  5)
dtoverlay=i2c3,pins_4_5   (board pins  7, 29)
# dtoverlay=i2c4,pins_6_7   (board pins 31, 26)
# dtoverlay=i2c5,pins_12_13 (board pins 32, 33)
# dtoverlay=i2c6,pins_22_23 (board pins 15, 16)

# *** SPI ***

dtparam=spi=on
dtoverlay=spi1-3cs

# *** End of config.txt ***

Appendix B - Python program listing to test I2C Speed Setting

Python program listing to test I2C Speed Setting


tlfong01
  • 4,847
  • 3
  • 12
  • 24
5

The maximum supported speed is 400 Kb/s.

I am not aware of any difference in the I2C implementation between Pi models.

The Broadcom Serial Controller (BSC) controller is a master, fast-mode (400Kb/s) BSC controller. The Broadcom Serial Control bus is a proprietary bus compliant with the Philips® I2C bus/interface version 2.1 January 2000.

See page 28 of BCM2835 ARM Peripherals.

As to whether any particular speed is achievable will depend on the wiring, termination, capacitance etc.

To change the I2C baud rate to 400 kb/s add the following entry to /boot/config.txt

dtparam=i2c_baudrate=400000

I just set 3MHz and the appropriate clock was sent. I don't have any devices which work at that speed so have no idea if it actually would work in practice.

enter image description here

joan
  • 71,852
  • 5
  • 76
  • 108
5

WIth an RPi 4: Using i2cdetect program to make the lines wiggle.

Using an oscilloscope, if I just enable i2c in the config.txt with no other lines in the file, I see 10usec SCL periods (100kHz).

Adding the i2c_baudrate=400000 to the config.txt file I see 2.5usec SCL periods (400kHz).

Have not done the same experiment with the RPi 3 yet but obviously runs at full speed on the 4. I can post pics if necessary...

Larry Klein
  • 217
  • 1
  • 3