amredries
Member level 2
real time clock
i have used real time clom ds1302 with pic 16f877
it seems that it work but i found that it count seconds from 0 to 99
not 60 seconds there somthing error happen when counting the seconds it jumps
for example 35 36 45
the code are
clock:
low rst 'reset the clock
low sclk
'set initial time 8:00am 16/07/99
rtcyear=$99
rtcday=$06
rtcmonth=$07
rtcdate=$16
rtchr=$08
rtcmin=0
rtcsec=0
gosub settime
'************************************************* **************
settime: 'set the time
rst=1 'enable data tx
shout io,sclk,lsbfirst,[$8e,0] 'enable write
rst=0 'reset RTC
rst=1 'ready for tx
'write all 8 RTC registers in burst mode
Shout io,sclk,LSBFIRST,[$be,rtcsec,rtcmin,rtchr,rtcdate,rtcmonth,rtcday,rt cyear,0]
rst=0 'reset RTC
return
'************************************************* **************
gettime: 'read the time from the RTC
rst=1 'ready for tx
shout io,sclk,LSBFIRST,[$bf] 'Read all 8 RTC registers in burst mode
Shin io,sclk,LSBPRE,[rtcsec,rtcmin,rtchr,rtcdate,rtcmonth,rtcday,rtcyea r,rtccontrol]
rst = 0 ' Reset RTC
Return
i am using picbasic
please help me
thanks
i have used real time clom ds1302 with pic 16f877
it seems that it work but i found that it count seconds from 0 to 99
not 60 seconds there somthing error happen when counting the seconds it jumps
for example 35 36 45
the code are
clock:
low rst 'reset the clock
low sclk
'set initial time 8:00am 16/07/99
rtcyear=$99
rtcday=$06
rtcmonth=$07
rtcdate=$16
rtchr=$08
rtcmin=0
rtcsec=0
gosub settime
'************************************************* **************
settime: 'set the time
rst=1 'enable data tx
shout io,sclk,lsbfirst,[$8e,0] 'enable write
rst=0 'reset RTC
rst=1 'ready for tx
'write all 8 RTC registers in burst mode
Shout io,sclk,LSBFIRST,[$be,rtcsec,rtcmin,rtchr,rtcdate,rtcmonth,rtcday,rt cyear,0]
rst=0 'reset RTC
return
'************************************************* **************
gettime: 'read the time from the RTC
rst=1 'ready for tx
shout io,sclk,LSBFIRST,[$bf] 'Read all 8 RTC registers in burst mode
Shin io,sclk,LSBPRE,[rtcsec,rtcmin,rtchr,rtcdate,rtcmonth,rtcday,rtcyea r,rtccontrol]
rst = 0 ' Reset RTC
Return
i am using picbasic
please help me
thanks