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

i2c speed

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



Joined: 04 Jun 2008
Posts: 23

View user's profile Send private message

i2c speed
PostPosted: Wed Sep 21, 2011 4:18 am     Reply with quote

Hello.
I want to use i2c routine with a speed lower than 100KHz. Can this be done with #use i2c?
Ihave now:
#use i2c(Master,SLOW,sda=PIN_C4,scl=PIN_C3,restart_wdt,force_hw)
Ttelmah



Joined: 11 Mar 2010
Posts: 19469

View user's profile Send private message

PostPosted: Wed Sep 21, 2011 4:40 am     Reply with quote

Probably....You can set a 'wanted' clock rate, with:

SLOW=50000 for example

However you need to read the data sheet for your chip. Using the hardware I2C, how fast and slow you can go will depend on the clock rate. The compiler will try to get as close as possible to what you ask for, but if the timing is not possible from your master clock, you can still end up with a very wrong value...
The exact details of the baud rate generator, depend on the chip involved, but (for example), if you were running off a 48MHz master clock with a 18F4550, the I2C clock is given by FOSC/(4*(SSPADD+1)). For the BRG, the SSPADD register is 7bit only, so the lowest clock rate that could be generated for this master clock, would be:

48000000/(4*(127+1)) = 93750Hz.

So for this particular chip running this fast, rates below 93750Hz, can't be done.

However if your master clock is slower, the corresponding rates drop....

Best Wishes
Best
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