Slow I2C

iainam

New Member
Hi, I want to use I2C at a slow bus speed, typically 10Khz. This is to allow longer cable lengths until I get a bus buffer sorted out. Data rate at the moment is not an issue.

Seems you can do something with the i2cslow, i2cfast commands but no matter what ( number ? ) I put in there I dont see any changes in bus speed.

Using 28X2 shield just now. Will mostly be driving 8 bit I/O expanders.

Any pointers appreciated.

iainam
 

nick12ab

Senior Member
Seems you can do something with the i2cslow, i2cfast commands but no matter what ( number ? ) I put in there I dont see any changes in bus speed.
Numbers where?

How are you '(not) seeing' changes in the bus speed?

Using a mode keyword for a higher clock speed (e.g i2cslow_32) should slow down the bus.
 

westaust55

Moderator
Have a look at the native/raw PIC Datasheet associated with the 28X2:
http://www.microchip.com/wwwproducts/Devices.aspx?product=PIC18F25K22

Section 15.3 covers the i2c hardware and at section 15.7 formula for determining i2c speeds (Bits/sec)
There is a table for some values but for more conventional speeds.

I have,for my model railway DCC accessory decoder project, gone the other way with a 28X2 clock speed of 80 MHz and i2c running at 1000 kHz for faster data transfer from a Slave 20X2.
 

iainam

New Member
Hi,

Thanks all for the replies, been busy for a few days... I am using an Intronix 34 analyzer to watch the i2c bus.

nick12ab:-
I think I was not entering the 12cslow parameter correctly. Hopefully I will have things properly set up this weekend and give it another try.
Do you have any idea of the range of numbers I can use in the i2cslow_XXX parameter, I suspect 1-255?
I will try anyway and publish my results here once I am done.

westaust55:-
I have also just downloaded the PIC datasheet so will have a look at that as well, good luck with you project, that is a seriously fast bus speed. I have never used
anything above 400KHz

Regards

iainam
 

Circuit

Senior Member
Hi,

Do you have any idea of the range of numbers I can use in the i2cslow_XXX parameter, I suspect 1-255?
I will try anyway and publish my results here once I am done.
The parameter is to indicate the clock speed that the PICAXE chip is running at so the correct i2c speed is achieved. The standard parameters are i2cslow_8; i2cslow_16; i2cslow_32 if the PICAXE is not running at the default 4MHz. See Manual 2 Page 79.
 

Buzby

Senior Member
Be careful with very slow I2C signals.

Some slave devices auto-reset if they don't see a signal transition within a certain period.

Check the datasheets of the slaves.
 

iainam

New Member
Hi,

after some time I finally have some results following the suggestions and comments given here.

Using a picaxe shield base as supplied, I have the following results from a simple command to a PCF8547 writing FF then 0.
Measured on SCL for the first 18 clock cycles

i2cslow_8 approx 220uS Same as i2cslow on its own.
i2cslow_16 approx 420uS
i2cslow_32 approx 800uS
i2cslow_64 approx 1.3mS

Numbers above 64 give a syntax error.

So I am now happy I can run my i2c bus slower than 100kHz

For information this was run using 10M of alarm type cable with 4k7 pullups at the far end of the cable where the PCF device was located.
Many thanks for the help and suggestions received here. Any comments appreciated.

Regards

Iain
 

westaust55

Moderator
You are not limited to using the predefined values with the names "i2cslow_xx".
You can also calculate your own values and either use directly or better via a SYMBOL statement such as:
SYMBOL i2c_myspeed = 55

The greater the number the slower the i2c clock speed.
As mentioned before, there is information and the required formula in the PIC datasheet.
 

iainam

New Member
Hi westaust55,

I never thought about that as I only tried the values above and got a syntax error above 64. The values I have are sufficient for the task at the moment but
I will look at the data sheet to see how low I can go in speed. (Comment from Busby noted) It has become a challenge for me to get maximum distance with minimal hardware. No real reason, just for the fun of it !

Many thanks, iain
 

darb1972

Senior Member
I have,for my model railway DCC accessory decoder project, gone the other way with a 28X2 clock speed of 80 MHz and i2c running at 1000 kHz for faster data transfer from a Slave 20X2.
Hello Westie. Without wanting to hijack this thread, I was interested to read about your DCC Accessory Decoder. I had a look at your project in the completed projects section. Very impressive stuff.

I am curious to know just how far one can take some of the PICAXE micro controllers in terms of clock speed? I was really surprised to read that you were able to take a 28X2 to 80MHz. Up until now I thought the maximum speed was 64MHz??? Do all of the commands (particularly involving time based commands) work at these speeds? This obviously demonstrates how little I really know about the PICAXE family of micro controllers.
 

westaust55

Moderator
Hi westaust55,

I never thought about that as I only tried the values above and got a syntax error above 64. The values I have are sufficient for the task at the moment but
I will look at the data sheet to see how low I can go in speed. (Comment from Busby noted) It has become a challenge for me to get maximum distance with minimal hardware. No real reason, just for the fun of it !

Many thanks, iain
The parameters "i2cslow_xx" are just predefined values. If you enter the following lines in the Programming Editor using the simulation mode you can see the actual pre-defined values.
b0 = i2cslow_4
b1 = i2cslow_8
:
b4 = i2cslow_32
b5 = i2cslow_64 (for X2 parts only)

using the simulation mode you can see the actual pre-defined values where:
b0 =137
b1 = 147
:
b4 = 207
b5 = 255
so clearly the parameter i2cslow_64 is already the largest byte value you can have.
 
Top