View previous topic :: View next topic |
Author |
Message |
Salenko
Joined: 08 Sep 2008 Posts: 84
|
I²C speed limit |
Posted: Sat Apr 04, 2009 5:31 am |
|
|
Hi,
I used the code below and add FAST=400khz, to both slave and master #use i2c () directive, code but the communication blocked in 400khz (but worked for 390khz and lower)
http://www.ccsinfo.com/forum/viewtopic.php?t=36695
I can work at frequency lower than 400 khz, but , if possible, I would like to know why 400khz is not possible to use. Is this frequency just theoric ?
any idea ?
thanks. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Apr 04, 2009 12:15 pm |
|
|
You didn't say what PIC you are using, but in many PIC data sheets,
there is a statement that the timing at 400 KHz does not meet the i2c
specification, and the "care should be used" at that frequency.
Tell us what PIC you are using, and also your compiler version. |
|
|
Ttelmah Guest
|
|
Posted: Sat Apr 04, 2009 2:48 pm |
|
|
Also what clock rate the PIC is running.
With some PIC's 400K, most certainly can work, but it does require low bus capacitances, low pull up resistors, and a fast master clock.
Best Wishes |
|
|
Salenko
Joined: 08 Sep 2008 Posts: 84
|
|
Posted: Sun Apr 05, 2009 4:40 am |
|
|
Hi PCM & Ttelmath,
thank you very much for your answers,
the master is a 16F877 PIC micro running at 20Mhz
the slave is a 16F876 PIC micro running at 10Mhz
my compiler is PCW 4.057
the master and the slave are placed in different boards (distance between them is about 12 inch ), besides, the master has two slaves in his board (an RTC and an EEPROM ) that's why I think I need a fast communication (but not necessary as fast as 400khz) , because the master has to stock data every minute in the EEPROM and get real time from the RTC (in addition to sending/receiving data to/from the 16F876 Micro but, this is not so frequent).
the pull-up resistances am using are 4.7k.
what do you think the approriate I2C speed to use ?, the resistance values ?, should I change the quartz ?.
thank you. |
|
|
Ttelmah Guest
|
|
Posted: Sun Apr 05, 2009 2:34 pm |
|
|
Reduce the resistors. At 400KHz, 4K7, limits you to a total bus capacitance of about 60pF. Add the pins on the chips, and your cabling, you may well be over this. 2K, is a more normal high speed value.
Realistically, I2C, is always easier, and more reliable if the slave is running at least as fast as the master.
Check the data sheets for your chips.
Best Wishes |
|
|
bsturm
Joined: 23 Feb 2009 Posts: 29
|
|
Posted: Mon Apr 06, 2009 9:33 pm |
|
|
I have a very similar application and I use slow I2C. It seems plenty fast to me and hopefully more reliable than fast I2C. I do have a slightly longer cable (~36") to my slave board. I also have 4k7 pullups at both ends. I had to add some delays to give the slave time to process, I don't think the clock stretching was working for me. You can find my recent posts for examples. In general, I always try to use the slowest possible communication rates. |
|
|
Salenko
Joined: 08 Sep 2008 Posts: 84
|
|
Posted: Wed Apr 08, 2009 7:49 am |
|
|
Ttelmah wrote: | Reduce the resistors. At 400KHz, 4K7, limits you to a total bus capacitance of about 60pF. Add the pins on the chips, and your cabling, you may well be over this. 2K, is a more normal high speed value.
Realistically, I2C, is always easier, and more reliable if the slave is running at least as fast as the master.
Check the data sheets for your chips.
Best Wishes |
thanks Ttelmah |
|
|
Salenko
Joined: 08 Sep 2008 Posts: 84
|
|
Posted: Wed Apr 08, 2009 7:51 am |
|
|
bsturm wrote: | I have a very similar application and I use slow I2C. It seems plenty fast to me and hopefully more reliable than fast I2C. I do have a slightly longer cable (~36") to my slave board. I also have 4k7 pullups at both ends. I had to add some delays to give the slave time to process, I don't think the clock stretching was working for me. You can find my recent posts for examples. In general, I always try to use the slowest possible communication rates. |
thank you bsturm, I'll take a look at your posts. |
|
|
|