PDA

View Full Version : Need help intergating a PIC16F628 with a DS1307



PNightmare
- 20th October 2007, 21:46
I'm trying to modify an existing project (the http://www.alan-parekh.com/hard_drive_clock.html ) and I only know very little about programming. The modifications I did to the base coding already is make it run on an external 4MHz crystal and added a second hand to the clock (instead of the 2 LED ports lighting up) on the RB3. Looking at the schematic, the RA0 to RA5 ports are free and so is port RB7. I have the DS1307 and the PIC16F628 chips and would like to interface them, but I don't know how to intagrate it into the exisiting coding.

I'm seeking your help here, because I believe Melanie wrote the original coding that's on the PICBasic site and it's the only coding that I can find interfacing a PIC16F628 with a DS1307 in PICBasic coding.

My modified source code is here and if you spot any bugs, please point them out:

Steve_88
- 20th October 2007, 22:29
Use Melanie's code by itself, once you have that working with the DS1307 then move on to integration.

Also this code you show is quite long, trying to debug it with new code being added will be a nightmare..........................

So start with getting small pieces of code to work at first and build upon it.

good luck

PNightmare
- 21st October 2007, 00:28
I'll try, it's going to be a pain to seperate what I can use for the coding

Josuetas
- 30th October 2007, 19:45
I have nevertheless an idea for you, the simple pic16F628 can work as a very good clock by itself, check Elapsed_Timer in the forum, if you are thinking on DS to keep time even when the device is off power then you can consider using the pic in low power too and using the same battery to keep him alive.

Note: you can use even less power with the pic using a 32Khz cristal really convinient if you want to measure time also ;)

If you insist in RTC there is not much more to say than the example and the datasheet. Using RTC is a simple i2C read or write BUT take into account that data is delivered and stored in BCD.

good luck