Shop OBEX P1 Docs P2 Docs Learn Events
400K I2C Object?! — Parallax Forums

400K I2C Object?!

James LongJames Long Posts: 1,181
edited 2009-12-22 06:48 in Propeller 1
Has anyone ever stripped out Mike Green's fast I2C object, or made one of their own.

I don't mind using his fast I2C but it has items in it that I can't use (using another object for the SD part). I would strip it out myself, but I'm scared I'll break it.

Anyone??


James L

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
James L
Partner/Designer
Lil Brother SMT Assembly Services

Are you addicted to technology or Micro-controllers..... then checkout the forums at Savage Circuits. Learn to build your own Gizmos!

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-12-22 06:33
    The assembly I2C driver was originally written for I2C only and the SPI / SD-card stuff was added later. Here's the original.
  • James LongJames Long Posts: 1,181
    edited 2009-12-22 06:39
    Mike Green said...
    The assembly I2C driver was originally written for I2C only and the SPI / SD-card stuff was added later. Here's the original.

    Mike,

    That is exactly what I needed. I'm using it to write to I/O expanders, and didn't need the SPI.

    I appreciate it.

    James L

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    James L
    Partner/Designer
    Lil Brother SMT Assembly Services

    Are you addicted to technology or Micro-controllers..... then checkout the forums at Savage Circuits. Learn to build your own Gizmos!
  • photomankcphotomankc Posts: 943
    edited 2009-12-22 06:41
    Me too. I'm going to need fast I2C and was just thinking about stripping that down the other day. Neat timing! Thanks Mike.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-12-22 06:42
    If you're going to use it at 400KHz, I suggest you change the timing as follows:
    PUB computeTimes                                       '' Set up timing constants in assembly
                                                           ' (Done this way to avoid overflow)
      i2cDataSet1 := ((clkfreq / 10000) *  900) / 100000   ' Data setup time -  900ns (100KHz)
      i2cClkLow1  := ((clkfreq / 10000) * 4700) / 100000   ' Clock low time  - 4700ns (100KHz)
      i2cClkHigh1 := ((clkfreq / 10000) * 4000) / 100000   ' Clock high time - 4000ns (100KHz)
      i2cDataSet4 := ((clkfreq / 10000) *  550) / 100000   ' Data setup time -  550ns (400KHz)
      i2cClkLow4  := ((clkfreq / 10000) * 1300) / 100000   ' Clock low time  - 1300ns (400KHz)
      i2cClkHigh4 := ((clkfreq / 10000) * 1000) / 100000   ' Clock high time - 1000ns (400KHz)
    


    Nick Mueller did some timing tests and recommended changes in the data setup times. These changes have already been made to the routines in FemtoBasic and its derivatives.
  • James LongJames Long Posts: 1,181
    edited 2009-12-22 06:48
    Mike Green said...
    If you're going to use it at 400KHz, I suggest you change the timing as follows:
    PUB computeTimes                                       '' Set up timing constants in assembly
                                                           ' (Done this way to avoid overflow)
      i2cDataSet1 := ((clkfreq / 10000) *  900) / 100000   ' Data setup time -  900ns (100KHz)
      i2cClkLow1  := ((clkfreq / 10000) * 4700) / 100000   ' Clock low time  - 4700ns (100KHz)
      i2cClkHigh1 := ((clkfreq / 10000) * 4000) / 100000   ' Clock high time - 4000ns (100KHz)
      i2cDataSet4 := ((clkfreq / 10000) *  550) / 100000   ' Data setup time -  550ns (400KHz)
      i2cClkLow4  := ((clkfreq / 10000) * 1300) / 100000   ' Clock low time  - 1300ns (400KHz)
      i2cClkHigh4 := ((clkfreq / 10000) * 1000) / 100000   ' Clock high time - 1000ns (400KHz)
    


    Nick Mueller did some timing tests and recommended changes in the data setup times. These changes have already been made to the routines in FemtoBasic and its derivatives.

    Mike,

    Roger that. I'll make the changes to insure speed compatibility.

    I have to add a few things to, that I am using which this version doesn't include. They all deal with the expanders, but it is much easier to add, than subtract.

    I do appreciate it.

    James L

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    James L
    Partner/Designer
    Lil Brother SMT Assembly Services

    Are you addicted to technology or Micro-controllers..... then checkout the forums at Savage Circuits. Learn to build your own Gizmos!
Sign In or Register to comment.