-1

I have set up i2c between a Raspberry Pi 4 and an Arduino with a level shifter. I have set the i2c baudrate in /boot/config.txt using

dtparam=i2c_arm_baudrate=400000

But when I look at the i2c clock signal with a USB ocilloscope, the period is 6.24 microseconds for a frequency of 160 kHz. Any ideas why this might be happening?

Even with the Arduino and the level shifter disconnected, I see 160 kHz.

I am using wiringPi in C on the Raspberry Pi.

Thanks,

Ryan

ryanGT
  • 27
  • 1
  • 1
  • 4

1 Answers1

1

Thanks Seamus, that fixed my issue. I saw that thread earlier and didn't think it was related. But if I set the cpu scaling to "performance" just before I run a test, the i2c clock period is exactly 2.5 microseconds, i.e. 400 kHz. This is the command from that other thread:

echo performance | sudo tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

It seems that the setting doesn't survive a reboot, so I either need to remember to run that command before my i2c program or I need to look into setting a constant cpu frequency in /boot/config.txt, or something.

For more details, this is the thread from Seamus' comment:

I2C baudrate in Raspberry Pi, depends on arm core frequency

Thanks again, Ryan

ryanGT
  • 27
  • 1
  • 1
  • 4