Issue2524 allow clocks below 100KHz#6934
Conversation
…nused slave STOP function
…nused slave STOP function
…nused slave STOP function
There was a problem hiding this comment.
@devyte - [review integer ranges for overflow, minor constness ]
edit: divide by zero if they feed it 0Hz, uint32_t overflow below 233Hz
edit2: there's no overflow, my test program above was mixing ints and unsigned ints (corrected). The real code was correct. I knew I'd checked my math twice to insure I stayed within an unsigned int!
Might want to limit the lower end even further, as a single byte read or write is ~78ms at 250Hz.
(start, 7 bits address, read/write, ack, 8 bits data, ack, stop). Maybe somewhere around 500Hz to 1KHz would be a better lower limit. I don't expect any more than a few people trying to run it lower than 10KHz, normally. There were some radio PLLs that needed ~ 10KHz bus clock back in the '80s, but that's ancient history.
devyte
left a comment
There was a problem hiding this comment.
Nice work here. Only minor changes before merge.

Corrects the fixed I2C bus clock selections and allows slower bus clocks down to ridiculously low bus speeds if you need that. Originally prompted by Earle's comment in #2524 about computing the bus clock timing.
Additionally, the dead Twi::stop was removed. The compiler was removing it in slave compiles anyways, as it wasn't called by any of the functions except for one oversight in the slave state machine. Slaves can't issue STOP commands. Although the Twi::stop was listed as an exposed function, it wasn't linked from Wire.h, so it was optimized out.