Skip to content

manually handle AVR i2c setspeed to handle slow clocks #104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 31, 2022

Conversation

ladyada
Copy link
Member

@ladyada ladyada commented Jul 31, 2022

prescaler is not calculated here https://github.com/arduino/ArduinoCore-avr/blob/master/libraries/Wire/src/utility/twi.c#L139 which means we cannot get below 30.5mhz!

cc @RobTillaart this fixes up AGS02MA behavior

@ladyada
Copy link
Member Author

ladyada commented Jul 31, 2022

issue opened at arduino/ArduinoCore-avr#495 in case they want a fix!

@RobTillaart
Copy link
Contributor

@ladyada
FYI,

I tried the prescaler solution in my AGS02MA library and could run I2C (on AVR) at 25 KHz and 10 KHz .
At 25 KHz I made 1000++ calls with ~1.5 second delay in between with zero errors.
At 30.4 KHz I had 2 error in ~500 calls in a test run.
So 25 KHz seems more stable, no visible performance loss. (25 KHz is an exact divider of 16 MHz)

Also I added a +1 on your issue for an TWSR aware I2C.setClock() - arduino/ArduinoCore-avr#495

@ladyada
Copy link
Member Author

ladyada commented Aug 10, 2022

yep all good - this is why i like wrappering i2c/spi in this way - theres just so many wierd dependancies and exceptions that our libraries got really complex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants