sukumar
stranger
Reged: Jul 12 2007
Posts: 4
Loc: Tamilnadu, INDIA
|
|
I already replied for a forum question, but i found it is useful if i post my code here, Enjoy with the code
-------------------- Sukumar.M
|
Arjun
stranger
Reged: Mar 21 2009
Posts: 7
|
|
i tried this code .. it doesnt work !!
|
Dan Henry
Guru
  
Reged: Oct 16 2003
Posts: 3872
Loc: Colorado
|
|
Quote:
i tried this code .. it doesnt work !!
You neglected to attach the fix you are sharing.
|
Arjun
stranger
Reged: Mar 21 2009
Posts: 7
|
|
Thank you Dan for pointing that out. Iv attached the fix this time around. i tried debugging it .. everything works well untill ds1307_init(); once the hardware goes into this function and calls DS1307Write() .. this is when the problem starts .. im using a PIC 16f877a with a 20 MHZ crystal ..
|
Dan Henry
Guru
  
Reged: Oct 16 2003
Posts: 3872
Loc: Colorado
|
|
Quote:
im using a PIC 16f877a with a 20 MHZ crystal ..
I think your I2C BRG is too fast. At 20MHz, shouldn't it be 63 for Fscl of 100KHz?
|
Arjun
stranger
Reged: Mar 21 2009
Posts: 7
|
|
i didnt get you .. 20 MHz is the crystal freq of 16f877 and the oscillator used with DS1307 is 32.769 KHz .. i appreciate your guidance !!
|
Dan Henry
Guru
  
Reged: Oct 16 2003
Posts: 3872
Loc: Colorado
|
|
Quote:
i didnt get you .. 20 MHz is the crystal freq of 16f877 and the oscillator used with DS1307 is 32.769 KHz .. i appreciate your guidance !!
What I was referring to has nothing to do with the RTC's oscillator, but rather about the I2C bus clocking frequency. That said, you can ignore my previous post. I had referred to table 9-3 in the data sheet, which is subject to MSSP errata that I had forgotten about. Your value of 49 is correct for 100KHz I2C bus clocking.
|
Arjun
stranger
Reged: Mar 21 2009
Posts: 7
|
|
:-) ya .. but i still can't figure out why SSPIF doesnt get set ..
|
Dan Henry
Guru
  
Reged: Oct 16 2003
Posts: 3872
Loc: Colorado
|
|
Do you have pull-ups on SDA and SCL?
|
Arjun
stranger
Reged: Mar 21 2009
Posts: 7
|
|
yes .. 10k each
|