pedrohenrique
Joined: 20 Jun 2008 Posts: 4
|
I2C NACK Avoidance and Recovery |
Posted: Thu May 21, 2009 3:13 am |
|
|
Hi.
I amd working on a project, programming a PIC18F4685 as master, interfacing with a DS1337 RTC, a 24LC256 EEPROM and a PIC16F886 by I2C.
I am using slow, software mode.
Code: |
#use I2C(MASTER,sda=PIN_C4,scl=PIN_C3,slow)
|
The RTC and EEPROM work perfectly, but the PIC communication frequently locks up. I tried to handle the ACK/NACK, but can't find a way to unlock the communication without a hard reset on both PICs.
Can anyone give me some hints on how to avoid these lockups and how to recover without resetting the PICs, should they occur?
I am also in doubt as to clock stretching. Is this a hardware function, or does it have to be implemented by software? If so, how is CCS, should it be done?
Thank you |
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun May 24, 2009 5:12 pm |
|
|
Disconnect all slave devices except the 16F886. Edit your Master code
so it only talks to the 16F886. Does it now work ?
If it fails, then post a small but complete test program for both Master
and Slave. The programs must be small. Each program should take
up less than one screen in an editor. The smaller they are, the easily
the problem can be spotted. |
|