felias-fogg / SoftI2CMaster

Software I2C Arduino library
GNU General Public License v3.0
368 stars 100 forks source link

Custom clock rate #79

Closed sonik-br closed 1 year ago

sonik-br commented 1 year ago

Hi,

I'm using the library for bitbang connection to a device as I don't have the hardware i2c pins free. And it works like a charm! :)

But I would like to have it running in an overclocked rate (higher than the common100kHz). Fast mode (400kHz) is too fast for the device.

If I want to use it at 200kHz, what values I need to set here?

felias-fogg commented 1 year ago

Hi,

frankly, I cannot remember, how these numbers were computed. However, looking at them, by interpolation I would choose a value around 180000 as the divisor. And, of course, you should verify the resulting using a scope or logic analyzer. In case, you do not own one already, I can recommend one of those el cheapo "24MHz 8ch logic analyzers". Have a look at my blog post on LAs: https://hinterm-ziel.de/index.php/2021/10/07/doing-it-the-logical-way/.

Cheers, Bernhard

sonik-br commented 1 year ago

Thank you.