atsams-rs / atsamx7x-rust

Rust HAL, PACs, and examples for the Microship SAM E70/S70/V70/V71
Apache License 2.0
25 stars 11 forks source link

Fix TWI clock Configuration #59

Closed martinmortsell closed 1 year ago

martinmortsell commented 1 year ago

Fixes #58 .

Updated the frequency configuration and related documentation. Added comment in I2cConfiguration noting that it will not be accurate for higher frequencies.

tmplt commented 1 year ago

I haven't read the relevant issue yet, nor reviewed the datasheet; after what frequency will problems manifest?

martinmortsell commented 1 year ago

It will depend on the physical characteristics of the specific board you're working with. I have a PCB with a single FRAM on the I2C bus, and 10kOhm pullup resistors and when I set the clock frequency to 400kHz in the HAL I get 325kHz as the actual SCL frequency.

That is fine for me, and fine for most applications - I2C is robust enough to handle longer rise times. And with e.g. 2.2kOhm pullups the rise time would be much smaller and the effect on the frequency less noticable.