0

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

1
  • I can't answer your question, but this Q&A may provide something you can use. Also, double-check the diffs between baud rate and clock frequency in i2c!
    – Seamus
    Jun 8 at 23:34

1 Answer 1

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.