PDA

View Full Version : Hello Can any one help me with this code (DS1307 RTCM With PIC16F877a)



Ali Al-Shaybani
- 20th September 2010, 14:04
Good Day everybody im new to this Programing Language so i was hopping if i can get help here???

so im interfacing the RTCM DS1307 with the 16F877A i know that there is alot of examples on the net but all of them show the values on an LCD i want to sent the time/date through hyperterminal.

so i found a code and i was trying to fix it for my need but no luck here it goes :(

'************************************************* ***************
Device = 16F877A
Config HS_OSC
Declare Bootloader = On
Declare I2C_BUS_SCL On
Xtal = 20
Hserial_Baud = 9600 ' Set baud rate to 9600
Hserial_RCSTA = %10010000 ' Enable serial port and continuous receive


ADCON1=7
DelayMS 100
High PORTA.0
TRISC= %11111111
SDA var PORTC.4
SCL var PORTC.3
DB0 var Byte[8]

CMCON = %00000111 ' Comparators = off

DelayMS 1000

GoSub Write_1307
read_1307:
' Read time Secs,Mins,Hours,Day,Date,Month,Year,Control
I2CIN SDA,SCL,$D1,$00,[Str DB0\8] ' Read 8 bytes from DS1307


HRSOut "Time=",Hex2 DB0[2],":",Hex2 DB0[1]
DelayMS 2000
End

Write_1307:
' Set time & date to 15:55:00 Tuesday 6th of July 2004
I2COUT SDA,SCL,$D0,$00,[$00,$55,$15,$2,$6,$7,$4,$90] ' Write to DS1307
DelayMS 10
Return ' Sec Min Hr Day D M Y Control
'********************************************

Acetronics2
- 20th September 2010, 14:48
Hello Ali

Are you sure you have posted on the right forum ???

Here, it is PicBasicPro from MELABS ... :rolleyes:

I remember there were one or two threads talking about DS1307, here ... so you can try a SEARCH ( upper right of your screen), to get some ideas ...

Alain