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 slow always fast

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



Joined: 01 Dec 2008
Posts: 3

View user's profile Send private message

I2C slow always fast
PostPosted: Mon Dec 01, 2008 6:29 pm     Reply with quote

Hi to all.
I am writing a simple program to write and read PCF8582 EEPROM.
The PCF8582C-2 operates in only the standard-speed mode (100KHz).

So I set my I2C in slow mode, using this:
Code:
#include <16F886.h>
#use delay(internal=8M)
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use I2C(master, sda=PIN_c4, scl=PIN_c3,slow)
 


and then I have written the writing routine, to write a byte to the eeprom.
If I check the ack, it is always missing, and anyway the I2C bus speed is always the same (fast).

Something is missing??
caosmaker



Joined: 01 Dec 2008
Posts: 3

View user's profile Send private message

PostPosted: Mon Dec 01, 2008 6:37 pm     Reply with quote

another thing... always related, that may be useful to understand the problem...
If I put the statement "FORCE_HW", the program hang... it stop in the "i2c_start();" sub.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Dec 01, 2008 6:55 pm     Reply with quote

Quote:
#include <16F886.h>
#use delay(internal=8M)
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use I2C(master, sda=PIN_c4, scl=PIN_c3,slow)

1. Don't use the 'HS' fuse with the internal oscillator. Use the INTRC_IO fuse.

2. The #use delay statement should go after the fuses.
caosmaker



Joined: 01 Dec 2008
Posts: 3

View user's profile Send private message

PostPosted: Tue Dec 02, 2008 2:19 am     Reply with quote

Thanks a lot... I try later, when I return home Smile
Ttelmah
Guest







PostPosted: Tue Dec 02, 2008 3:31 am     Reply with quote

Also, just include a speed with the defintion. So:
#use I2C(master, sda=PIN_c4, scl=PIN_c3,slow=25000)

or whatever you want.

Best Wishes
epalite



Joined: 06 Apr 2008
Posts: 16

View user's profile Send private message

PostPosted: Thu Jun 25, 2009 12:53 am     Reply with quote

Quote:

#use I2C(master, sda=PIN_c4, scl=PIN_c3,slow=25000)


Hi, exactly how does the "SLOW" and "FAST" affect the SCL? And when do we use each of them?
Ttelmah
Guest







PostPosted: Thu Jun 25, 2009 2:49 am     Reply with quote

Historically, 'slow' selected the highest speed possible, _below_ 100KHz. Fast, the highest speed possible below 400KHz. In software I2C mode, you are unlikely to get a speed over 'slow', from an 8Mhz crystal. I'd expect something like perhaps 30 to 50KHz to be the fastest achievable. Then with V4, the option to specify the rate was added. Slow and fast, then basically behave the same, if the same rate is selected, _except_ on some chips wth programmable slew rate, for the hardware I2C, 'fast' will select the higher speed option for this.

The only normal reasons fo a hang on I2C start, with the hardware I2C, are:
1) TRIS bit set to 0 on SCL or SDA line. The compiler will correctly set these at initialisation, but if you perform an output operation on these bits, overriding the TRIS, this will cause a hang.
2) The lines are not properly pulled high, before starting. What pull up resistors hve you got on the I2C lines?.

The commonest error, is forgetting the pull up resistors. These are _required_ for I2C.

Best Wishes
epalite



Joined: 06 Apr 2008
Posts: 16

View user's profile Send private message

PostPosted: Thu Jun 25, 2009 2:55 am     Reply with quote

Ttelmah wrote:
Then with V4, the option to specify the rate was added. Slow and fast, then basically behave the same, if the same rate is selected,...


Hi, didn't quite understand this "V4" option. Do you mean, say,

#use I2C(master, sda=PIN_c4, scl=PIN_c3,slow=100000)

and

#use I2C(master, sda=PIN_c4, scl=PIN_c3,fast=100000)

are essentially the same?
Ttelmah
Guest







PostPosted: Thu Jun 25, 2009 4:51 am     Reply with quote

Unless the chip has slew rate control, yes.

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