Hi!!I've read your program!!
But i'm searching somethink more simple, i'll try to explain:
' Allocate variables
Dim rtcyear as byte
Dim rtcday as byte
Dim rtcmonth as byte
Dim rtcdate as byte
Dim rtchr as byte
Dim rtcmin as byte
Dim rtchr1 as byte
Dim rtcmin1 as byte
Dim rtcsec as byte
Dim rtccontrol as byte
dim b0 as byte
dim b1 as byte
'-------------------------------------------------------------------------------
Low RST ' Reset RTC
Low SCLK
ADCON1 = 7 ' PORTA and E digital
Low PORTE.2 ' LCD R/W low = write
Delayms 100 ' Wait for LCD to startup
' Set initial time to 8:00:00AM 07/16/99
rtcyear = $99
rtcday = $06
rtcmonth = $07
rtcdate = $16
'rtchr = 0
'rtcmin = 0
'rtchr1 = 0
'rtcmin1 = 0
rtcsec = 0
if portb.1=1 then goto impostime
Gosub settime ' Set the time
Goto mainloop ' Skip subroutines
'-------------------------------------------------------------------------------
' Subroutine to set time
impostime:
if portb.1=0 then return else
pause 20
b0=0
button portb.2,1,255,255,b0,1,settore
pause 20
b1=0
button portb.3,1,255,255,b1,1,settminuti
pause 20
print at 3,1, dec2 rtchr, ";", dec2 rtcmin
goto impostime
settminuti:
pause 20
rtchr1=rtchr1+1
if rtchr1 =24 then rtchr1=0 else endif
rtchr=rtchr1
goto impostime
settore:
pause 20
rtcmin1=rtcmin1+1
if rtcmin1=60 then rtcmin1=0 else endif
rtcmin=rtcmin1
goto impostime
'--------------------------------------------------------------------------------
' Subroutine to write time to RTC
Settime:
RST = 1 ' Ready for transfer
Shout IO,SCLK,LSBFIRST,[$8e,0] ' Enable write
RST = 0 ' Reset RTC
RST = 1 ' Ready for transfer
' 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
This program doesn't work because if i used the two buttons to set the initial time all works till i'm under "9", for example if i want to set hour=10 then i will read "A" in the display!
But if i don't use the buttons to select the initial time, and i write rtchour=$10 then i will read "10" on the display!
Who can tell me were is the mistake?!?!
i have to make a conversion before writing on the ds?!
help me please!
Bookmarks