View Full Version : I2C Max frequency by SPIN
01-18-2008, 11:29 AM
Propeller run at 80 MHz.
This is a section in Write Subroutine of I2C_Driver:
T1 := cnt
outa[SDA] := (data <-= 1) & 1 ' Output data to SDA
outa[SCL]~~ ' Toggle SCL from LOW to HIGH to LOW
T2 : = cnt -T1
Result: T2 = 23392 counts (for 8 loops) thus, each loop = 2924 counts
Therefore, SCL = 27.36 kHz (80000000/2924)
If everything is correct, we can not drive I2C device (with 400 kHz clk) by SPIN.
Is there an I2C_driver in Assembly?
01-18-2008, 11:52 AM
Sorry, I just missed the previous post about I2C speeding up. Please ignore this post.
01-18-2008, 12:24 PM
The I2C routines included with FemtoBasic (downloadable from the Propeller Object Exchange) are written in assembly, can be used separately from FemtoBasic, and will run at 100KHz and 400KHz (selectable).
Beau Schwabe (Parallax)
01-18-2008, 01:29 PM
deSilva had mentioned a site that graphically showed the effects of R and C...
To follow up on this I simulated what was on this page and got similar results.
I also changed the parameters so that the I2C voltage level was 3.3V and the SCL line was at 400KHz.
Based on this information, at 400KHz I would probably use a 1K to 2.2K pullup resistor leaning more towards the 1K.
Beau Schwabe (mailto:email@example.com)
IC Layout Engineer
Post Edited (Beau Schwabe (Parallax)) : 1/18/2008 6:36:06 AM GMT
01-18-2008, 04:30 PM
Beau, I always appreciated your "experimental" mind! It is good to see signals on the 'scope!
Also, there is always a difference between 3V and 5V supply (to the worse, alas!) that we tend to forget when having figures from the "old time" in our mind http://forums.parallax.com/images/smilies/smile.gif
My problem is still that I cannot explain where 150pF should come from on a soldered board...
Post Edited (deSilva) : 1/18/2008 9:35:27 AM GMT
01-18-2008, 08:49 PM
Not for the faint hearted, but generally informative on this topic:
01-18-2008, 10:22 PM
I also tracked down deSilva's link.
I found the attached charts which show pull-up resistance as functions of bus capacitance and also supply voltage.
This would support Beau's recommendation of 1K pull-up, although that is at the absolute minimum allowed for 3.3V supply.
It might be safer to go a little higher.