Shop OBEX P1 Docs P2 Docs Learn Events
I2C Max frequency by SPIN — Parallax Forums

I2C Max frequency by SPIN

Michael07Michael07 Posts: 12
edited 2008-01-18 15:22 in Propeller 1
Propeller run at 80 MHz.

This is a section in Write Subroutine of I2C_Driver:
T1 := cnt
repeat 8
outa[noparse][[/noparse]SDA] := (data <-= 1) & 1 ' Output data to SDA
outa[noparse][[/noparse]SCL]~~ ' Toggle SCL from LOW to HIGH to LOW
outa[noparse][[/noparse]SCL]~
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?

Thank you.

Michael

Comments

  • Michael07Michael07 Posts: 12
    edited 2008-01-18 04:52
    Sorry, I just missed the previous post about I2C speeding up. Please ignore this post.

    Michael
  • Mike GreenMike Green Posts: 23,101
    edited 2008-01-18 05:24
    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 SchwabeBeau Schwabe Posts: 6,559
    edited 2008-01-18 06:29
    Michael07,

    deSilva had mentioned a site that graphically showed the effects of R and C...

    http://www.i2c-bus.org/Termination-versus-Capacitance.530.0.html

    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.

    attachment.php?attachmentid=51522


    ·


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 1/18/2008 6:36:06 AM GMT
    662 x 279 - 62K
    I2C.JPG 61.5K
  • deSilvadeSilva Posts: 2,967
    edited 2008-01-18 09:30
    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 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
  • Don DDon D Posts: 27
    edited 2008-01-18 13:49
    Not for the faint hearted, but generally informative on this topic:

    http://lsiwww.epfl.ch/LSI2001/teaching/webcourse/ch04/ch04.html
  • mynet43mynet43 Posts: 644
    edited 2008-01-18 15:22
    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.

    Jim
Sign In or Register to comment.