[riot-notifications] [RIOT-OS/RIOT] cpu/stm_common/i2c: set fast mode flag (#10773)

MrKevinWeiss notifications at github.com
Wed Jan 16 10:22:49 CET 2019

Well so far this is what I have found out...
First some stats (BOARD=nucleo-f401re, DUT=PHiLIP, 470 ohm external pullups used/needed)
According to the datasheet, setting that bit changes the Tlow
Sm mode or SMBus:
Thigh = CCR * TPCLK1
Tlow = CCR * TPCLK1
Fm mode:
If DUTY = 0:
Thigh = CCR * TPCLK1
Tlow = 2 * CCR * TPCLK1
If DUTY = 1: (to reach 400 kHz)
Thigh = 9 * CCR * TPCLK1
Tlow = 16 * CCR * TPCLK1
This is reflected in the traces below (white traces are with fast mode bit set, yellow without).  

This however messes up the frequency setting (with the new fast mode the 400 kHz signal becomes around 250 kHz).

Accoding to the [specs](https://www.nxp.com/docs/en/user-guide/UM10204.pdf) it states:

> A Fast-mode I2C-bus device can be used in a Standard-mode I2C-bus system, but the requirement tSU;DAT 250 ns must then be met. This will automatically be the case if the
device does not stretch the LOW period of the SCL signal. If such a device does stretch the LOW period of the SCL signal, it must output the next data bit to the SDA line
tr(max) + tSU;DAT = 1000 + 250 = 1250 ns (according to the Standard-mode I2C-bus specification) before the SCL line is released. Also the acknowledge timing must meet this
set-up time.

Which may be why it was working fine.

It also shows that standard mode needs a `Tlow=4.7us` `Thigh=4.0` about 55% duty cycle for the min requirements.  For fast mode it needs  `Tlow=1.3us` `Thigh=0.6` about 70% duty cycle for the min time.

This would probably by why the chip has a different duty cycle in the modes.

Now with this information we must also decide what is better.  If we think that a weaker pullup resistor will reduce the effective Thigh time (because it takes a while to charge) then we can use less power for the speed.  If we keep it at 50% duty cycle and we use very strong pullups then the Tlow would be 50% of 400kHz = 1.25us (out of spec).

Let me know what you think after digesting this info (power/speed vs safety decision)

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190116/bb1a83dd/attachment.html>

More information about the notifications mailing list