View previous topic :: View next topic |
Author |
Message |
andyd
Joined: 08 Mar 2007 Posts: 30
|
How fast is "fast" (I2C)? |
Posted: Mon Apr 23, 2007 2:16 am |
|
|
Just wondering what clock speed the I2C bus runs at when "fast" is specified in #use i2c? I'm assuming it's PIC clock speed dependent, but the CCS manual doesn't go into a great amount of detail. Also tried looking on the datasheet for my PIC (16F88 if relevant), but that doesn't mention it either (though it does for SPI).
Just trying to work out if I can gain anything by using a faster version of my EEPROM (currently using a 24AA1025 which can run at 400kHz, the 24LC1025 can go up to 1MHz), and if so how I setup my PIC to use a higher I2C clock speed if its possible. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Mon Apr 23, 2007 2:34 am |
|
|
You can specify the speed yourself. Use 'FAST=1000000', to get I2C at 1Mhz (if your clock supports it).
Now traditional I2C, supports two rates. 100KHz max for the standard rate, and 400KHz max for fast devices. It is the latter that 'FAST' will default to trying to generate. However it will then be limited according to the clock rate of the chip, and whether software, or hardware I2C is involved. For 'software' I2C, it takes several instructions to send each bit, and you are unlikley to get 400KHz on anything running below perhaps 40MHz. On hardware I2C, the rate will depend on the available multiplier from the cystal. The software will select the multiplier that develops the highest possible frequency _below_ 400KHz, unlkess you specify a higher 'target'.
Remember that for operation at the higher rate (and even worse above this), your line capcitances need to be more tightly controlled, and the pull-up resistor value carefully selected, if the system is to work reliably. I have I2C, running nicely at 1MHz, but used high current capability I2C driver IC's, running with a smaller pull-up resistor to get fast edges on the lines.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
C-H Wu Guest
|
I2C driver IC's |
Posted: Mon Apr 23, 2007 3:39 am |
|
|
Hi, Ttelmah:
can you recommand some I2C driver IC's ?
thanks a lot
C-H Wu |
|
![](templates/subSilver/images/spacer.gif) |
andyd
Joined: 08 Mar 2007 Posts: 30
|
|
Posted: Mon Apr 23, 2007 9:19 am |
|
|
I've changed my code to "fast = 400000" and stuck a scope on the SCL pin of my PIC and all I'm getting is 91kHz. Using a 16F88 running on its internal 8MHz oscillator with 10k pullups on the SDA and SCL lines and a 24AA1025.
What's the difference between software and hardware I2C (apart from the obvious)? I'm using the designated SDA/SCL pins on my PIC, but using CCS functions such as i2c_read etc., so what am I using?
If I am using hardware, what are going to be the limiting factors? |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Mon Apr 23, 2007 9:58 am |
|
|
The F88, has a full hardware I2C _slave_, but only partial I2C 'master'.
This is the difference between chips with the 'SSP' module, and those with the 'MSSP' module. Unfortunately, this makes the hardware master mode very hard to implement on this chip (you basically have to 'bodge' the start and stop bit generation), and I'd therefore expect the CCS code to use software for the master mode on this chip, which is why your speed is so limited.
10K, is too large for the pull-ups, for 'fast' mode. It is above the specified 'maximum' value, for any likely bus capacitance value. Typically a value more like perhaps 1.7K is needed. However unless you change PIC, you won't get to clock this fast...
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
andyd
Joined: 08 Mar 2007 Posts: 30
|
|
Posted: Tue May 01, 2007 8:48 am |
|
|
I've now changed resistors to lower values and to an F886 which should have MI2C according to the Microchip site, but my SCL line has now got even slower (62 kHz)! Are there any special bits I need to set to put it in some kind of fast mode or make CCS realise that it has hardware I2C? |
|
![](templates/subSilver/images/spacer.gif) |
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
Posted: Tue May 01, 2007 9:50 am |
|
|
From the help file
in #use I2c
Quote: | Software functions are generated unless the FORCE_HW is specified. |
perhaps this is the problem? |
|
![](templates/subSilver/images/spacer.gif) |
andyd
Joined: 08 Mar 2007 Posts: 30
|
|
Posted: Wed May 02, 2007 8:50 am |
|
|
That's great! Should really have thought to look there! I now have I2C running nicely at 396kHz which has really helped things ![Smile](images/smiles/icon_smile.gif) |
|
![](templates/subSilver/images/spacer.gif) |
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Wed May 02, 2007 2:26 pm |
|
|
If you want to make sure your signals are as clean as possible, you might want to look at a bus driver to help out. I've used LTC1694 on different I2C applications and it works quite well. It might help keep the bus from acting too noisy.
Ronald |
|
![](templates/subSilver/images/spacer.gif) |
|