execuc / u2if

USB to interfaces implementing MicroPython "machine" module functionalities on a computer.
Other
152 stars 26 forks source link

i2c frequency accuracy #8

Closed charkster closed 2 years ago

charkster commented 2 years ago

Great project, I'm really excited to have i2c access on my Ubuntu desktop. I was trying your scan_i2c.py example and measured the SCL period with a logic analyzer and oscilloscope.

i2c = I2C(i2c_index=0, frequency=400000) resulted in a frequency of 357kHz (about 11% lower) requesting frequency=450000 measured exactly 400kHz

i2c = I2C(i2c_index=0, frequency=1000000) resulted in a frequency of 791kHz (about 21% lower) requesting frequency=1350000 measured exactly 1MHz

I'm fine using these new values for my scripts, but I thought I would pass on the observation.

charkster commented 2 years ago

SPI clock is dead-on. Tried 1MHz, 8MHz, 10MHz looked a bit goofy... I would probably only run with a max of 8MHz.

charkster commented 2 years ago

WIth a 2K Ohm pullup to 3.3V I am measuring 376kHz for a 400kHz setting and 881kHz for a 1MHz setting. My previous measurements were done with a slave attached but only using ones on the slave (4.7k Ohm).

charkster commented 2 years ago

I am thinking this is a hardware inaccuracy rather than software... I'm too lazy to install the arduino libraries for the Pico to check the accuracy there.