Content originally posted in LPCWare by Wouter on Fri Jan 18 04:21:43 MST 2013
Hi Dave,
A bitrate lower than set by the I2CSCLH and I2CSCLL register is something that can be typically expected. As explained earlier, I2C slave devices may use clock stretching. The I2C master supports this feature by carefully watching the SCL line, wait for SCL to become high (atleast 0.7VDD) and then keep SCL high for as long as specified in the I2SCLH register. Therefore, the risetime influences the bitrate.
The 3-12 mA spec you mention is only for the HS mode, not for Fast-Mode. The minimum value of the pull-up resistor depends on the VDD, and can be found in figure 37, page 40. With VDD=3.3V, this would be about 1.2k when no series resistor is used. The maximum value of the pull-up resistor is limited by the risetime (thus also by busloading etc.). For Fast-Mode, the maximum risetime is 300ns (Table 5, Page 32). Looking at the waveform from your first post, you have about 300ns of risetime (best guess, but hard to see at current timebase). So your 2.4k pull-ups seem to be about the maximum. Now, 400KHz would give a period time of 2.5us. However, due to your 300ns risetime you would have a period time of 2.5+0.3 = 2.8us = a frequency of 357KHz! Of course this is very confusing because of the formula given in the user manual. I'll submit a request to add a remark to the user manual to clarify this.
But, this makes the gap between the measured bitrate of 336KHz and expected bitrate (now 357KHz instead of 400KHz) already a lot less (~21KHz). I'm not really sure where this difference comes from, but I see about the same over here.
I used the EA1788 board, pin P5.3 (SCL). No bus load, pull-up of 2.4k, configured for 400KHz (I2SCLH = I2SCLL = 75):
- Measured frequency is 387KHz, risetime is 200ns.
- Expected frequency is 1/(2.5us + 0.2us) = 370KHz
Gap between expected and measured bitrate is ~17KHz...
I hope this explains to you why the measured bitrate is different than what you would expect, and that a difference of 20KHz is okay for you.
Regards,
Wouter