PICmicro & dsPIC >> Source Share for PICmicro & dsPIC

Pages: 1 | 2 | >> (show all)
sukumar
stranger


Reged: Jul 12 2007
Posts: 4
Loc: Tamilnadu, INDIA
DS1307 interfacing with PIC16f877 or 877a
      #28414 - Thu Jul 12 2007 07:41 AM Attachment (782 downloads)

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


Post Extras: Print Post   Remind Me!   Notify Moderator  
Arjun
stranger


Reged: Mar 21 2009
Posts: 7
Re: DS1307 interfacing with PIC16f877 or 877a [Re: sukumar]
      #103512 - Wed Mar 25 2009 05:58 PM

i tried this code .. it doesnt work !!

Post Extras: Print Post   Remind Me!   Notify Moderator  
Dan HenryModerator
Guru
****

Reged: Oct 16 2003
Posts: 3872
Loc: Colorado
Re: DS1307 interfacing with PIC16f877 or 877a [Re: Arjun]
      #103562 - Thu Mar 26 2009 12:42 AM

Quote:

i tried this code .. it doesnt work !!



You neglected to attach the fix you are sharing.


Post Extras: Print Post   Remind Me!   Notify Moderator  
Arjun
stranger


Reged: Mar 21 2009
Posts: 7
Re: DS1307 interfacing with PIC16f877 or 877a [Re: Dan Henry]
      #103842 - Fri Mar 27 2009 10:31 AM Attachment (199 downloads)

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 ..


Post Extras: Print Post   Remind Me!   Notify Moderator  
Dan HenryModerator
Guru
****

Reged: Oct 16 2003
Posts: 3872
Loc: Colorado
Re: DS1307 interfacing with PIC16f877 or 877a [Re: Arjun]
      #103872 - Fri Mar 27 2009 11:55 AM

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?


Post Extras: Print Post   Remind Me!   Notify Moderator  
Arjun
stranger


Reged: Mar 21 2009
Posts: 7
Re: DS1307 interfacing with PIC16f877 or 877a [Re: Dan Henry]
      #103882 - Fri Mar 27 2009 12:18 PM

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 !!


Post Extras: Print Post   Remind Me!   Notify Moderator  
Dan HenryModerator
Guru
****

Reged: Oct 16 2003
Posts: 3872
Loc: Colorado
Re: DS1307 interfacing with PIC16f877 or 877a [Re: Arjun]
      #103952 - Fri Mar 27 2009 02:51 PM

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.


Post Extras: Print Post   Remind Me!   Notify Moderator  
Arjun
stranger


Reged: Mar 21 2009
Posts: 7
Re: DS1307 interfacing with PIC16f877 or 877a [Re: Dan Henry]
      #103962 - Fri Mar 27 2009 03:21 PM

:-)
ya .. but i still can't figure out why SSPIF doesnt get set ..


Post Extras: Print Post   Remind Me!   Notify Moderator  
Dan HenryModerator
Guru
****

Reged: Oct 16 2003
Posts: 3872
Loc: Colorado
Re: DS1307 interfacing with PIC16f877 or 877a [Re: Arjun]
      #103972 - Fri Mar 27 2009 03:23 PM

Do you have pull-ups on SDA and SCL?

Post Extras: Print Post   Remind Me!   Notify Moderator  
Arjun
stranger


Reged: Mar 21 2009
Posts: 7
Re: DS1307 interfacing with PIC16f877 or 877a [Re: Dan Henry]
      #104002 - Sat Mar 28 2009 09:57 AM

yes .. 10k each

Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1 | 2 | >> (show all)



Extra information
0 registered and 23 anonymous users are browsing this forum.

Moderator:  jtemples, Dan Henry, Andrew L, mikerj 

Print Topic

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is enabled
      UBBCode is enabled

Rating:
Topic views: 9198

Rate this topic

Jump to

Contact Us | Privacy statement HI-TECH Software

Powered by UBB.threads™ 6.5.5