Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Real Time Clock

Status
Not open for further replies.

VRL_15

New Member
How to implement a RTC without using any timer in PIC 16F887 ?

How to use DS1307 to achieve RTC for PIC?
 
How to implement a RTC without using any timer in PIC 16F887 ?

How to use DS1307 to achieve RTC for PIC?
Yup, a DS1307 is a good way to do it. You'll need a DS1307, a 3V battery holder and battery off an old computer mainboard, three pullup resistors 4.7K to 10K, one 0.1uF ceramic cap, and a 32.768kHz crystal. Wire it up as shown in the datasheet and write some code. Or just buy a RTC module with all that stuff built for you (I'm using this one from Futurlec at present). The code isn't too terribly difficult, though it's a bit daunting at first. After you're immersed in it for a while you realize it's actually pretty simple.

Coincidentally I just happen to have finally decided to learn I2C last night, using one of the DS1307's I've had kicking around here for a long time. To learn it properly I'm writing my own code, and not using the MSSP module on the PIC 18F14K50 that I'm working with (at this point I consider that cheating). I have all my write code working well (the 1307's oscillator is working and it's outputting a 1Hz pulse on SQW/OUT that I have blinking an LED), but still have to tune up the read code. When that's done I'll post my newby code on my web-site.

ds1307002sm.jpg

I did run into one thing that wasted some time finding the problem. I was running the DS1307 at 3.3V. It "pretends" to work at that voltage, but when you write to it all it sends back are nacks (negative acknowledge). I finally read the datasheet more carefully and found that it won't work right at 3.3V. Powered it with 5V and all the nacks turned to acks - my code had been correct all along. :p I'd have wasted more time if I didn't have a analyzer to show me what was happening with my pulses - I love that thing!

The source code I found most helpful (borrowed from it a bit :D ) was Mike Pearce's I2C Routines, posted on Microchip's site.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top