i2c overclocking up to 1Mhz

Post here first, or if you can't find a relevant section!
victor_pv
Posts: 1681
Joined: Mon Apr 27, 2015 12:12 pm

Re: i2c overclocking up to 1Mhz

Post by victor_pv » Sun Oct 08, 2017 5:16 am

Dannyf sorry for any confusion. I know how to overclock the port, I was asking if other people considers that it would be helpful if I send my core in as PR to be incorporated in the core.

victor_pv
Posts: 1681
Joined: Mon Apr 27, 2015 12:12 pm

Re: i2c overclocking up to 1Mhz

Post by victor_pv » Sun Oct 08, 2017 5:28 am

RogerClark wrote:
Sat Oct 07, 2017 9:14 pm
I think we should add this feature..

Im pretty sure I looked at the Due code and it supported other speeds - though just an expanded list of speed settings.
( I presumed perhaps the SAM architecture only had a liminted number of speeds which the hardware could operate at, because the API call accepts the frequency, and the code just finds the nearest available freq that the hardware supports. Either that or someone at Arduino just decided on those arbitary steps)
The arduino API documents several other speeds (1Mhz, 3.4Mhz) but mentions that the user needs to check what's supported in his hardware.
From my tests with FRAM I was able to realibly get up to 1.3Mhz, and Racemaniac was able to get around the same speed before having problems.
The peripheral can work at many different speeds with the right settings, but I understand the standard i2c speeds are only a few.
So we can take both paths, set only the standard speeds with an enum (100Khz, 400Khz, 1Mhz), or just allow any speed within the range. I wrote my code in the second form since I wanted to test how fast it could go beyong 400Khz.
For reference the DUE allows any speed and just calculates the register values that match the best, but imposes to limit:
https://github.com/arduino/ArduinoCore- ... e.cpp#L140
https://github.com/arduino/ArduinoCore- ... twi.c#L114

stevestrong
Posts: 1748
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: i2c overclocking up to 1Mhz

Post by stevestrong » Sun Oct 08, 2017 8:43 am

Maybe these predefined values would make sense:

Code: Select all

100kHz
400kHz
1MHz
MAX_FREQUENCY

dannyf
Posts: 147
Joined: Wed May 11, 2016 4:29 pm

Re: i2c overclocking up to 1Mhz

Post by dannyf » Sun Oct 08, 2017 11:34 am

Set the i2c frequency based on F_I2C, which can be mapped to any number the user wishes to, including a few pre-defined macros, like F_I2C_100Khz, F_I2C_400Khz, ....

best of both worlds.

Post Reply