CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

How fast is "fast" (I2C)?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
andyd



Joined: 08 Mar 2007
Posts: 30

View user's profile Send private message

How fast is "fast" (I2C)?
PostPosted: Mon Apr 23, 2007 2:16 am     Reply with quote

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.
Ttelmah
Guest







PostPosted: Mon Apr 23, 2007 2:34 am     Reply with quote

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
C-H Wu
Guest







I2C driver IC's
PostPosted: Mon Apr 23, 2007 3:39 am     Reply with quote

Hi, Ttelmah:

can you recommand some I2C driver IC's ?

thanks a lot

C-H Wu
andyd



Joined: 08 Mar 2007
Posts: 30

View user's profile Send private message

PostPosted: Mon Apr 23, 2007 9:19 am     Reply with quote

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?
Ttelmah
Guest







PostPosted: Mon Apr 23, 2007 9:58 am     Reply with quote

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
andyd



Joined: 08 Mar 2007
Posts: 30

View user's profile Send private message

PostPosted: Tue May 01, 2007 8:48 am     Reply with quote

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?
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Tue May 01, 2007 9:50 am     Reply with quote

From the help file
in #use I2c
Quote:
Software functions are generated unless the FORCE_HW is specified.


perhaps this is the problem?
andyd



Joined: 08 Mar 2007
Posts: 30

View user's profile Send private message

PostPosted: Wed May 02, 2007 8:50 am     Reply with quote

That's great! Should really have thought to look there! I now have I2C running nicely at 396kHz which has really helped things Smile
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Wed May 02, 2007 2:26 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group