PDA

View Full Version : 400K I2C Object?!



James Long
12-22-2009, 02:11 PM
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 (http://www.lil-brother.com)

Are you addicted to technology or Micro-controllers..... then checkout the forums at Savage Circuits (http://www.savagecircuits.com). Learn to build your own Gizmos!

Mike Green
12-22-2009, 02:33 PM
The assembly I2C driver was originally written for I2C only and the SPI / SD-card stuff was added later. Here's the original.

James Long
12-22-2009, 02:39 PM
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 (http://www.lil-brother.com)

Are you addicted to technology or Micro-controllers..... then checkout the forums at Savage Circuits (http://www.savagecircuits.com). Learn to build your own Gizmos!

photomankc
12-22-2009, 02:41 PM
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 Green
12-22-2009, 02:42 PM
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 Long
12-22-2009, 02:48 PM
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 (http://www.lil-brother.com)

Are you addicted to technology or Micro-controllers..... then checkout the forums at Savage Circuits (http://www.savagecircuits.com). Learn to build your own Gizmos!