|
|
View previous topic :: View next topic |
Author |
Message |
caosmaker
Joined: 01 Dec 2008 Posts: 3
|
I2C slow always fast |
Posted: Mon Dec 01, 2008 6:29 pm |
|
|
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
|
|
Posted: Mon Dec 01, 2008 6:37 pm |
|
|
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
|
|
Posted: Mon Dec 01, 2008 6:55 pm |
|
|
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
|
|
Posted: Tue Dec 02, 2008 2:19 am |
|
|
Thanks a lot... I try later, when I return home |
|
|
Ttelmah Guest
|
|
Posted: Tue Dec 02, 2008 3:31 am |
|
|
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
|
|
Posted: Thu Jun 25, 2009 12:53 am |
|
|
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
|
|
Posted: Thu Jun 25, 2009 2:49 am |
|
|
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
|
|
Posted: Thu Jun 25, 2009 2:55 am |
|
|
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
|
|
Posted: Thu Jun 25, 2009 4:51 am |
|
|
Unless the chip has slew rate control, yes.
Best Wishes |
|
|
|
|
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
|