Shop OBEX P1 Docs P2 Docs Learn Events
---DS1302--- timekeeper help please — Parallax Forums

---DS1302--- timekeeper help please

ArchiverArchiver Posts: 46,084
edited 2003-03-07 01:11 in General Discussion
I am having trouble with a ds1302 timekeeper. I used the
basic code from parallax (below). I loaded the current time and date. What the
debug screen shows is,
" 00:09:01 81/01/81"

I replaced the ds1302 and xtal with a spare, and got the same result. I checked
all the connections and all seem
to be okay......
Has anyone experienced this before ? any help with a solution would be
appreciated.......

Larry

'***************************************************************************
'* Title: DS1302_2.BS2 Author: Jeff A Martin Date: 5/18/98 *
'* *
'* Description: Shortened version of DS1302_1.BS2. *
'* *
'***************************************************************************

DATA (49)
RTCCmd VAR BYTE
Clk CON 0
Dta CON 1
RTCReset CON 2
Temp VAR BYTE
Seconds VAR BYTE
Minutes VAR BYTE
Hours VAR BYTE
Date VAR BYTE
Month VAR BYTE
Year VAR BYTE
I VAR BYTE
'Define Constants
SecReg CON %00000
MinReg CON %00001
HrsReg CON %00010
DateReg CON %00011
MonReg CON %00100
YrReg CON %00110
CtrlReg CON %00111
BrstReg CON %11111
DIRS = %0000000000111111
OUTS = %0000000000000000
' Clear Write Protect bit in control register
Temp = $10 '
RTCCmd = CtrlReg
GOSUB WriteRTC
Temp = $03 'year
RTCCmd = YrReg
GOSUB WriteRTC
Temp = $10 'hours
RTCCmd = HrsReg
GOSUB WriteRTC
Temp = $01 'month
RTCCmd = MonReg
GOSUB WriteRTC
Temp = $23 'date
RTCCmd = DateReg
GOSUB WriteRTC
Temp = $33 'minutes
RTCCmd = MinReg
GOSUB WriteRTC
Temp = $55 'seconds
RTCCmd = SecReg
GOSUB WriteRTC
Temp = $00 '
RTCCmd = CtrlReg
GOSUB WriteRTC
GOSUB ReadRTCBurst
DEBUG HOME, cr,cr,cr,cr," ",DEC Hours.HIGHNIB,DEC Hours.LOWNIB,":",DEC
Minutes.HIGHNIB
DEBUG DEC Minutes.LOWNIB,":",DEC Seconds.HIGHNIB,DEC Seconds.LOWNIB
DEBUG " ",DEC Month.HIGHNIB,DEC Month.LOWNIB,"/"
DEBUG DEC Date.HIGHNIB, DEC Date.LOWNIB,"/",DEC Year.HIGHNIB, DEC Year.LOWNIB,CR
WriteRTCRAM:
'Write to DS1202 RTC
HIGH RTCReset
SHIFTOUT Dta, Clk, LSBFIRST, [noparse][[/noparse]%0\1,RTCCmd\5,%11\2,Temp]
LOW RTCReset
RETURN
WriteRTC:
'Write to DS1202 RTC
HIGH RTCReset
SHIFTOUT Dta, Clk, LSBFIRST, [noparse][[/noparse]%0\1,RTCCmd\5,%10\2,Temp]
LOW RTCReset
RETURN
ReadRTCBurst:
HIGH RTCReset
SHIFTOUT DTA, Clk, LSBFIRST, [noparse][[/noparse]%1\1,BrstReg\5,%10\2]
SHIFTIN DTA, Clk, LSBPRE, [noparse][[/noparse]Seconds,Minutes,Hours,Date,Month,Year,Year]
LOW RTCReset
RETURN
ReadRTCRAM:
HIGH RTCReset
SHIFTOUT DTA, Clk, LSBFIRST, [noparse][[/noparse]%1\1,RTCCmd\5,%11\2]
SHIFTIN DTA, Clk, LSBPRE, [noparse][[/noparse]Temp]
LOW RTCReset
RETURN




[noparse][[/noparse]Non-text portions of this message have been removed]

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2003-03-05 16:10
    In a message dated 03/05/2003 10:55:40 Eastern Standard Time,
    forked_river@w... writes:


    > I am having trouble with a ds1302 timekeeper. I used the
    > basic code from parallax (below). I loaded the current time and date. What
    > the debug screen shows is,
    > " 00:09:01 81/01/81"
    >
    >

    What did you load?

    Sid


    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-03-05 17:05
    Dear Larry,
    i have used the clock chip in the past and the code was cleared of some
    bugs a long time ago when i couldn't get it to work either. this was done
    by Parallax. it works fine now. i will try and find the floppy with the
    code ASAP and post it for you. I also found that in order to maintain the
    battery backup line you needed to put a 10k on the RST line too which was at
    the time not shown on the original app note. The code that i was fortunate
    to get from Parallax was one that let you put switches in the BS2 to set the
    time just like a simple digital clock with a blinking cursor. It worked
    great. Hold tight and I will find the floppy and post it. Just have to
    find the right one in a mass of BS2 confusion. If you need help
    immediately, contact me directly at:
    mocenter@e...
    mike m
    Original Message
    From: Lawrence Freeze <forked_river@w...>
    To: <basicstamps@yahoogroups.com>
    Sent: Wednesday, March 05, 2003 10:45 AM
    Subject: [noparse][[/noparse]basicstamps] ---DS1302--- timekeeper help please


    > I am having trouble with a ds1302 timekeeper. I used the
    > basic code from parallax (below). I loaded the current time and date. What
    the debug screen shows is,
    > " 00:09:01 81/01/81"
    >
    > I replaced the ds1302 and xtal with a spare, and got the same result. I
    checked all the connections and all seem
    > to be okay......
    > Has anyone experienced this before ? any help with a solution would be
    appreciated.......
    >
    > Larry
    >
    >
    '***************************************************************************
    > '* Title: DS1302_2.BS2 Author: Jeff A Martin Date: 5/18/98 *
    > '* *
    > '* Description: Shortened version of DS1302_1.BS2. *
    > '* *
    >
    '***************************************************************************
    >
    > DATA (49)
    > RTCCmd VAR BYTE
    > Clk CON 0
    > Dta CON 1
    > RTCReset CON 2
    > Temp VAR BYTE
    > Seconds VAR BYTE
    > Minutes VAR BYTE
    > Hours VAR BYTE
    > Date VAR BYTE
    > Month VAR BYTE
    > Year VAR BYTE
    > I VAR BYTE
    > 'Define Constants
    > SecReg CON %00000
    > MinReg CON %00001
    > HrsReg CON %00010
    > DateReg CON %00011
    > MonReg CON %00100
    > YrReg CON %00110
    > CtrlReg CON %00111
    > BrstReg CON %11111
    > DIRS = %0000000000111111
    > OUTS = %0000000000000000
    > ' Clear Write Protect bit in control register
    > Temp = $10 '
    > RTCCmd = CtrlReg
    > GOSUB WriteRTC
    > Temp = $03 'year
    > RTCCmd = YrReg
    > GOSUB WriteRTC
    > Temp = $10 'hours
    > RTCCmd = HrsReg
    > GOSUB WriteRTC
    > Temp = $01 'month
    > RTCCmd = MonReg
    > GOSUB WriteRTC
    > Temp = $23 'date
    > RTCCmd = DateReg
    > GOSUB WriteRTC
    > Temp = $33 'minutes
    > RTCCmd = MinReg
    > GOSUB WriteRTC
    > Temp = $55 'seconds
    > RTCCmd = SecReg
    > GOSUB WriteRTC
    > Temp = $00 '
    > RTCCmd = CtrlReg
    > GOSUB WriteRTC
    > GOSUB ReadRTCBurst
    > DEBUG HOME, cr,cr,cr,cr," ",DEC Hours.HIGHNIB,DEC Hours.LOWNIB,":",DEC
    Minutes.HIGHNIB
    > DEBUG DEC Minutes.LOWNIB,":",DEC Seconds.HIGHNIB,DEC Seconds.LOWNIB
    > DEBUG " ",DEC Month.HIGHNIB,DEC Month.LOWNIB,"/"
    > DEBUG DEC Date.HIGHNIB, DEC Date.LOWNIB,"/",DEC Year.HIGHNIB, DEC
    Year.LOWNIB,CR
    > WriteRTCRAM:
    > 'Write to DS1202 RTC
    > HIGH RTCReset
    > SHIFTOUT Dta, Clk, LSBFIRST, [noparse][[/noparse]%0\1,RTCCmd\5,%11\2,Temp]
    > LOW RTCReset
    > RETURN
    > WriteRTC:
    > 'Write to DS1202 RTC
    > HIGH RTCReset
    > SHIFTOUT Dta, Clk, LSBFIRST, [noparse][[/noparse]%0\1,RTCCmd\5,%10\2,Temp]
    > LOW RTCReset
    > RETURN
    > ReadRTCBurst:
    > HIGH RTCReset
    > SHIFTOUT DTA, Clk, LSBFIRST, [noparse][[/noparse]%1\1,BrstReg\5,%10\2]
    > SHIFTIN DTA, Clk, LSBPRE, [noparse][[/noparse]Seconds,Minutes,Hours,Date,Month,Year,Year]
    > LOW RTCReset
    > RETURN
    > ReadRTCRAM:
    > HIGH RTCReset
    > SHIFTOUT DTA, Clk, LSBFIRST, [noparse][[/noparse]%1\1,RTCCmd\5,%11\2]
    > SHIFTIN DTA, Clk, LSBPRE, [noparse][[/noparse]Temp]
    > LOW RTCReset
    > RETURN
    >
    >
    >
    >
    > [noparse][[/noparse]Non-text portions of this message have been removed]
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2003-03-05 18:10
    Well, your first GOSUB RTCWrite looks like it is
    SETTING the Write-Protect bit ($10), instead of
    CLEARING it ($00) -- so in theory none of your
    writes will work...

    Note that a 'cleared' 1302 reads:
    Sunday, Jan 01, 2000, 12:00:80 AM
    or: Day 1, Month 1, Date 1, Year 00, Hour 12,
    Minute 00, Second 80.

    I used program DS1302_1.BS2 from the same source, and it
    works very well.

    --- In basicstamps@yahoogroups.com, "Lawrence Freeze"
    <forked_river@w...> wrote:
    > I am having trouble with a ds1302 timekeeper. I used the
    > basic code from parallax (below). I loaded the current time and
    date. What the debug screen shows is,
    > " 00:09:01 81/01/81"
    >
    > I replaced the ds1302 and xtal with a spare, and got the same
    result. I checked all the connections and all seem
    > to be okay......
    > Has anyone experienced this before ? any help with a solution
    would be appreciated.......
    >
    > Larry
    >
    > '*******************************************************************
    ********
    > '* Title: DS1302_2.BS2 Author: Jeff A Martin Date: 5/18/98 *
    > '* *
    > '* Description: Shortened version of DS1302_1.BS2. *
    > '* *
    > '*******************************************************************
    ********
    >
    > DATA (49)
    > RTCCmd VAR BYTE
    > Clk CON 0
    > Dta CON 1
    > RTCReset CON 2
    > Temp VAR BYTE
    > Seconds VAR BYTE
    > Minutes VAR BYTE
    > Hours VAR BYTE
    > Date VAR BYTE
    > Month VAR BYTE
    > Year VAR BYTE
    > I VAR BYTE
    > 'Define Constants
    > SecReg CON %00000
    > MinReg CON %00001
    > HrsReg CON %00010
    > DateReg CON %00011
    > MonReg CON %00100
    > YrReg CON %00110
    > CtrlReg CON %00111
    > BrstReg CON %11111
    > DIRS = %0000000000111111
    > OUTS = %0000000000000000
    > ' Clear Write Protect bit in control register
    > Temp = $10 '
    > RTCCmd = CtrlReg
    > GOSUB WriteRTC
    > Temp = $03 'year
    > RTCCmd = YrReg
    > GOSUB WriteRTC
    > Temp = $10 'hours
    > RTCCmd = HrsReg
    > GOSUB WriteRTC
    > Temp = $01 'month
    > RTCCmd = MonReg
    > GOSUB WriteRTC
    > Temp = $23 'date
    > RTCCmd = DateReg
    > GOSUB WriteRTC
    > Temp = $33 'minutes
    > RTCCmd = MinReg
    > GOSUB WriteRTC
    > Temp = $55 'seconds
    > RTCCmd = SecReg
    > GOSUB WriteRTC
    > Temp = $00 '
    > RTCCmd = CtrlReg
    > GOSUB WriteRTC
    > GOSUB ReadRTCBurst
    > DEBUG HOME, cr,cr,cr,cr," ",DEC Hours.HIGHNIB,DEC
    Hours.LOWNIB,":",DEC Minutes.HIGHNIB
    > DEBUG DEC Minutes.LOWNIB,":",DEC Seconds.HIGHNIB,DEC Seconds.LOWNIB
    > DEBUG " ",DEC Month.HIGHNIB,DEC Month.LOWNIB,"/"
    > DEBUG DEC Date.HIGHNIB, DEC Date.LOWNIB,"/",DEC Year.HIGHNIB, DEC
    Year.LOWNIB,CR
    > WriteRTCRAM:
    > 'Write to DS1202 RTC
    > HIGH RTCReset
    > SHIFTOUT Dta, Clk, LSBFIRST, [noparse][[/noparse]%0\1,RTCCmd\5,%11\2,Temp]
    > LOW RTCReset
    > RETURN
    > WriteRTC:
    > 'Write to DS1202 RTC
    > HIGH RTCReset
    > SHIFTOUT Dta, Clk, LSBFIRST, [noparse][[/noparse]%0\1,RTCCmd\5,%10\2,Temp]
    > LOW RTCReset
    > RETURN
    > ReadRTCBurst:
    > HIGH RTCReset
    > SHIFTOUT DTA, Clk, LSBFIRST, [noparse][[/noparse]%1\1,BrstReg\5,%10\2]
    > SHIFTIN DTA, Clk, LSBPRE,
    [noparse][[/noparse]Seconds,Minutes,Hours,Date,Month,Year,Year]
    > LOW RTCReset
    > RETURN
    > ReadRTCRAM:
    > HIGH RTCReset
    > SHIFTOUT DTA, Clk, LSBFIRST, [noparse][[/noparse]%1\1,RTCCmd\5,%11\2]
    > SHIFTIN DTA, Clk, LSBPRE, [noparse][[/noparse]Temp]
    > LOW RTCReset
    > RETURN
    >
    >
    >
    >
    > [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-03-05 20:39
    many thanks, I hope you can find the floppy....

    Larry
    Original Message
    From: "M. E. M. Electronics" <memelectronics@e...>
    To: <basicstamps@yahoogroups.com>
    Sent: Wednesday, March 05, 2003 12:05 PM
    Subject: Re: [noparse][[/noparse]basicstamps] ---DS1302--- timekeeper help please


    > Dear Larry,
    > i have used the clock chip in the past and the code was cleared of some
    > bugs a long time ago when i couldn't get it to work either. this was done
    > by Parallax. it works fine now. i will try and find the floppy with the
    > code ASAP and post it for you. I also found that in order to maintain
    the
    > battery backup line you needed to put a 10k on the RST line too which was
    at
    > the time not shown on the original app note. The code that i was
    fortunate
    > to get from Parallax was one that let you put switches in the BS2 to set
    the
    > time just like a simple digital clock with a blinking cursor. It worked
    > great. Hold tight and I will find the floppy and post it. Just have to
    > find the right one in a mass of BS2 confusion. If you need help
    > immediately, contact me directly at:
    > mocenter@e...
    > mike m
    >
    Original Message
    > From: Lawrence Freeze <forked_river@w...>
    > To: <basicstamps@yahoogroups.com>
    > Sent: Wednesday, March 05, 2003 10:45 AM
    > Subject: [noparse][[/noparse]basicstamps] ---DS1302--- timekeeper help please
    >
    >
    > > I am having trouble with a ds1302 timekeeper. I used the
    > > basic code from parallax (below). I loaded the current time and date.
    What
    > the debug screen shows is,
    > > " 00:09:01 81/01/81"
    > >
    > > I replaced the ds1302 and xtal with a spare, and got the same result. I
    > checked all the connections and all seem
    > > to be okay......
    > > Has anyone experienced this before ? any help with a solution would be
    > appreciated.......
    > >
    > > Larry
    > >
    > >
    >
    '***************************************************************************
    > > '* Title: DS1302_2.BS2 Author: Jeff A Martin Date: 5/18/98 *
    > > '* *
    > > '* Description: Shortened version of DS1302_1.BS2. *
    > > '* *
    > >
    >
    '***************************************************************************
    > >
    > > DATA (49)
    > > RTCCmd VAR BYTE
    > > Clk CON 0
    > > Dta CON 1
    > > RTCReset CON 2
    > > Temp VAR BYTE
    > > Seconds VAR BYTE
    > > Minutes VAR BYTE
    > > Hours VAR BYTE
    > > Date VAR BYTE
    > > Month VAR BYTE
    > > Year VAR BYTE
    > > I VAR BYTE
    > > 'Define Constants
    > > SecReg CON %00000
    > > MinReg CON %00001
    > > HrsReg CON %00010
    > > DateReg CON %00011
    > > MonReg CON %00100
    > > YrReg CON %00110
    > > CtrlReg CON %00111
    > > BrstReg CON %11111
    > > DIRS = %0000000000111111
    > > OUTS = %0000000000000000
    > > ' Clear Write Protect bit in control register
    > > Temp = $10 '
    > > RTCCmd = CtrlReg
    > > GOSUB WriteRTC
    > > Temp = $03 'year
    > > RTCCmd = YrReg
    > > GOSUB WriteRTC
    > > Temp = $10 'hours
    > > RTCCmd = HrsReg
    > > GOSUB WriteRTC
    > > Temp = $01 'month
    > > RTCCmd = MonReg
    > > GOSUB WriteRTC
    > > Temp = $23 'date
    > > RTCCmd = DateReg
    > > GOSUB WriteRTC
    > > Temp = $33 'minutes
    > > RTCCmd = MinReg
    > > GOSUB WriteRTC
    > > Temp = $55 'seconds
    > > RTCCmd = SecReg
    > > GOSUB WriteRTC
    > > Temp = $00 '
    > > RTCCmd = CtrlReg
    > > GOSUB WriteRTC
    > > GOSUB ReadRTCBurst
    > > DEBUG HOME, cr,cr,cr,cr," ",DEC Hours.HIGHNIB,DEC Hours.LOWNIB,":",DEC
    > Minutes.HIGHNIB
    > > DEBUG DEC Minutes.LOWNIB,":",DEC Seconds.HIGHNIB,DEC Seconds.LOWNIB
    > > DEBUG " ",DEC Month.HIGHNIB,DEC Month.LOWNIB,"/"
    > > DEBUG DEC Date.HIGHNIB, DEC Date.LOWNIB,"/",DEC Year.HIGHNIB, DEC
    > Year.LOWNIB,CR
    > > WriteRTCRAM:
    > > 'Write to DS1202 RTC
    > > HIGH RTCReset
    > > SHIFTOUT Dta, Clk, LSBFIRST, [noparse][[/noparse]%0\1,RTCCmd\5,%11\2,Temp]
    > > LOW RTCReset
    > > RETURN
    > > WriteRTC:
    > > 'Write to DS1202 RTC
    > > HIGH RTCReset
    > > SHIFTOUT Dta, Clk, LSBFIRST, [noparse][[/noparse]%0\1,RTCCmd\5,%10\2,Temp]
    > > LOW RTCReset
    > > RETURN
    > > ReadRTCBurst:
    > > HIGH RTCReset
    > > SHIFTOUT DTA, Clk, LSBFIRST, [noparse][[/noparse]%1\1,BrstReg\5,%10\2]
    > > SHIFTIN DTA, Clk, LSBPRE, [noparse][[/noparse]Seconds,Minutes,Hours,Date,Month,Year,Year]
    > > LOW RTCReset
    > > RETURN
    > > ReadRTCRAM:
    > > HIGH RTCReset
    > > SHIFTOUT DTA, Clk, LSBFIRST, [noparse][[/noparse]%1\1,RTCCmd\5,%11\2]
    > > SHIFTIN DTA, Clk, LSBPRE, [noparse][[/noparse]Temp]
    > > LOW RTCReset
    > > RETURN
    > >
    > >
    > >
    > >
    > > [noparse][[/noparse]Non-text portions of this message have been removed]
    > >
    > >
    > > To UNSUBSCRIBE, just send mail to:
    > > basicstamps-unsubscribe@yahoogroups.com
    > > from the same email address that you subscribed. Text in the Subject
    and
    > Body of the message will be ignored.
    > >
    > >
    > > Your use of Yahoo! Groups is subject to
    http://docs.yahoo.com/info/terms/
    > >
    > >
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2003-03-05 20:48
    Allan,

    Thanks for the info. I made the change to 00, and unfortunatly got the same
    result..

    Larry

    Original Message
    From: "Allan Lane" <allan.lane@h...>
    To: <basicstamps@yahoogroups.com>
    Sent: Wednesday, March 05, 2003 1:10 PM
    Subject: [noparse][[/noparse]basicstamps] Re: ---DS1302--- timekeeper help please


    > Well, your first GOSUB RTCWrite looks like it is
    > SETTING the Write-Protect bit ($10), instead of
    > CLEARING it ($00) -- so in theory none of your
    > writes will work...
    >
    > Note that a 'cleared' 1302 reads:
    > Sunday, Jan 01, 2000, 12:00:80 AM
    > or: Day 1, Month 1, Date 1, Year 00, Hour 12,
    > Minute 00, Second 80.
    >
    > I used program DS1302_1.BS2 from the same source, and it
    > works very well.
    >
    > --- In basicstamps@yahoogroups.com, "Lawrence Freeze"
    > <forked_river@w...> wrote:
    > > I am having trouble with a ds1302 timekeeper. I used the
    > > basic code from parallax (below). I loaded the current time and
    > date. What the debug screen shows is,
    > > " 00:09:01 81/01/81"
    > >
    > > I replaced the ds1302 and xtal with a spare, and got the same
    > result. I checked all the connections and all seem
    > > to be okay......
    > > Has anyone experienced this before ? any help with a solution
    > would be appreciated.......
    > >
    > > Larry
    > >
    > > '*******************************************************************
    > ********
    > > '* Title: DS1302_2.BS2 Author: Jeff A Martin Date: 5/18/98 *
    > > '* *
    > > '* Description: Shortened version of DS1302_1.BS2. *
    > > '* *
    > > '*******************************************************************
    > ********
    > >
    > > DATA (49)
    > > RTCCmd VAR BYTE
    > > Clk CON 0
    > > Dta CON 1
    > > RTCReset CON 2
    > > Temp VAR BYTE
    > > Seconds VAR BYTE
    > > Minutes VAR BYTE
    > > Hours VAR BYTE
    > > Date VAR BYTE
    > > Month VAR BYTE
    > > Year VAR BYTE
    > > I VAR BYTE
    > > 'Define Constants
    > > SecReg CON %00000
    > > MinReg CON %00001
    > > HrsReg CON %00010
    > > DateReg CON %00011
    > > MonReg CON %00100
    > > YrReg CON %00110
    > > CtrlReg CON %00111
    > > BrstReg CON %11111
    > > DIRS = %0000000000111111
    > > OUTS = %0000000000000000
    > > ' Clear Write Protect bit in control register
    > > Temp = $10 '
    > > RTCCmd = CtrlReg
    > > GOSUB WriteRTC
    > > Temp = $03 'year
    > > RTCCmd = YrReg
    > > GOSUB WriteRTC
    > > Temp = $10 'hours
    > > RTCCmd = HrsReg
    > > GOSUB WriteRTC
    > > Temp = $01 'month
    > > RTCCmd = MonReg
    > > GOSUB WriteRTC
    > > Temp = $23 'date
    > > RTCCmd = DateReg
    > > GOSUB WriteRTC
    > > Temp = $33 'minutes
    > > RTCCmd = MinReg
    > > GOSUB WriteRTC
    > > Temp = $55 'seconds
    > > RTCCmd = SecReg
    > > GOSUB WriteRTC
    > > Temp = $00 '
    > > RTCCmd = CtrlReg
    > > GOSUB WriteRTC
    > > GOSUB ReadRTCBurst
    > > DEBUG HOME, cr,cr,cr,cr," ",DEC Hours.HIGHNIB,DEC
    > Hours.LOWNIB,":",DEC Minutes.HIGHNIB
    > > DEBUG DEC Minutes.LOWNIB,":",DEC Seconds.HIGHNIB,DEC Seconds.LOWNIB
    > > DEBUG " ",DEC Month.HIGHNIB,DEC Month.LOWNIB,"/"
    > > DEBUG DEC Date.HIGHNIB, DEC Date.LOWNIB,"/",DEC Year.HIGHNIB, DEC
    > Year.LOWNIB,CR
    > > WriteRTCRAM:
    > > 'Write to DS1202 RTC
    > > HIGH RTCReset
    > > SHIFTOUT Dta, Clk, LSBFIRST, [noparse][[/noparse]%0\1,RTCCmd\5,%11\2,Temp]
    > > LOW RTCReset
    > > RETURN
    > > WriteRTC:
    > > 'Write to DS1202 RTC
    > > HIGH RTCReset
    > > SHIFTOUT Dta, Clk, LSBFIRST, [noparse][[/noparse]%0\1,RTCCmd\5,%10\2,Temp]
    > > LOW RTCReset
    > > RETURN
    > > ReadRTCBurst:
    > > HIGH RTCReset
    > > SHIFTOUT DTA, Clk, LSBFIRST, [noparse][[/noparse]%1\1,BrstReg\5,%10\2]
    > > SHIFTIN DTA, Clk, LSBPRE,
    > [noparse][[/noparse]Seconds,Minutes,Hours,Date,Month,Year,Year]
    > > LOW RTCReset
    > > RETURN
    > > ReadRTCRAM:
    > > HIGH RTCReset
    > > SHIFTOUT DTA, Clk, LSBFIRST, [noparse][[/noparse]%1\1,RTCCmd\5,%11\2]
    > > SHIFTIN DTA, Clk, LSBPRE, [noparse][[/noparse]Temp]
    > > LOW RTCReset
    > > RETURN
    > >
    > >
    > >
    > >
    > > [noparse][[/noparse]Non-text portions of this message have been removed]
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    >
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2003-03-05 20:54
    Sid,
    I loaded the following. I also tried loading different combinations of times
    and dates to see if the errors followed a pattern. They did not...
    Thanks

    Temp = $03 'year
    Temp = $10 'hours
    Temp = $01 'month
    Temp = $23 'date
    Temp = $33 'minutes
    Temp = $55 'seconds
    -
    Larry
    ---- Original Message
    From: <Newzed@a...>
    To: <basicstamps@yahoogroups.com>
    Sent: Wednesday, March 05, 2003 11:10 AM
    Subject: Re: [noparse][[/noparse]basicstamps] ---DS1302--- timekeeper help please


    > In a message dated 03/05/2003 10:55:40 Eastern Standard Time,
    > forked_river@w... writes:
    >
    >
    > > I am having trouble with a ds1302 timekeeper. I used the
    > > basic code from parallax (below). I loaded the current time and date.
    What
    > > the debug screen shows is,
    > > " 00:09:01 81/01/81"
    > >
    > >
    >
    > What did you load?
    >
    > Sid
    >
    >
    > [noparse][[/noparse]Non-text portions of this message have been removed]
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2003-03-05 21:14
    Larry, it looks like you are using the same variable "temp" for everything,
    which isn't going to work. I'm going to try to attach a program that does
    work. If you dopn't get the attachment, contact me off line. The list might
    not accept attachments.

    Sid


    '{$STAMP BS2}
    '{$PBASIC 2.0}
    ' File : Stamp Clock_Display V1.5.1
    ' Date : 04/06/02
    ' Use with Clock_Temp Display V1.5.1
    ' Version: V1.5.1
    'For use with PC Board. May be breadboarded.
    '
    '
    ' DS1302 Function Pin Notes
    '



    ' 1 +5
    ' 2 Xtal
    ' 3 Xtal
    ' 4 Ground
    ' 5 Rst B.5 Pull down to ground through 10K
    ' 6 Dio B.6 Connect to bus through 1K if bus is shared
    ' 7 Clk B.7
    ' 8 Vcc2 Not used


    '
    [noparse][[/noparse] Constants ]
    '
    N9600 con 16468
    N2400 CON 16780
    Clock con 15 ' DS1302.7
    Dio con 14 ' DS1302.6
    Rst con 13 ' DS1302.5
    tempin con 12
    red con 11
    dataout con 9
    WrBrst CON $BE ' same as 190
    RdBrst CON $BF ' same as 191


    T24hr CON 0
    T12hr CON 1
    AM CON 0
    PM CON 1

    '
    [noparse][[/noparse] Variables ]
    x var word
    secs var byte
    mins var byte
    hrs var byte
    date var byte
    month var byte
    day var byte
    year var byte
    ctrl var byte
    tMode var hrs.Bit7
    tempstr var byte(3)
    timestr var byte(6)
    oldSc var byte
    com var byte(2)
    newtemp var word

    '
    [noparse][[/noparse] EEPROM Data ]
    '
    'Day1 DATA "Sun"
    'Day2 DATA "Mon"
    'Day3 DATA "Tue"
    'Day4 DATA "Wed"
    'Day5 DATA "Thu"
    'Day6 DATA "Fri"
    'Day7 DATA "Sat"


    '
    [noparse][[/noparse] Initialization ]
    '
    oldSc = $99

    '
    [noparse][[/noparse] Main Code ]

    Serout 16, N9600, [noparse][[/noparse]"Press 1 to read time", 13,10]
    serout 16, N9600, [noparse][[/noparse]"Press 2 to reset time ",13,10]
    serin 16, N9600, [noparse][[/noparse]com]
    begin:
    if com = "2" then newtime 'Red PB
    if com = "1" then telltime 'Black PB
    goto begin

    newtime:

    serout 16, N9600, [noparse][[/noparse]cr,"Enter Hex Month", cr]
    serin 16, N9600, [noparse][[/noparse]hex2 com]
    month = com
    serout 16, N9600, [noparse][[/noparse]cr,"Enter Hex Date", cr]
    serin 16, N9600, [noparse][[/noparse]hex2 com]
    date = com
    serout 16, N9600, [noparse][[/noparse]cr,"Enter Hex Year", cr]
    serin 16, N9600, [noparse][[/noparse]hex2 com]
    year = com
    serout 16, N9600, [noparse][[/noparse]cr,"Enter Hex Hours",cr]
    serin 16, N9600, [noparse][[/noparse]hex2 com]
    hrs = com
    serout 16, N9600, [noparse][[/noparse]cr,"Enter Hex Minutes", cr]
    serin 16, N9600, [noparse][[/noparse]hex2 com]
    mins = com
    serout 16, N9600, [noparse][[/noparse]cr,"Enter Hex Seconds", cr]
    serin 16, N9600, [noparse][[/noparse] hex2 com]
    secs = com
    serout 16, N9600, [noparse][[/noparse]cr,hex2 month, "/", hex2 date, "/", hex2 year, " ", hex2
    hrs, ":", hex2 mins, ":", hex2 secs, cr]

    set1:

    tmode = T24hr
    GOSUB SetClk

    telltime:
    high red
    pause 100
    low red

    GOSUB GetClk
    GOSUB ShowTm


    EndLp: GOTO telltime


    '
    [noparse][[/noparse] Subroutines ]
    '
    SetClk: HIGH Rst

    SHIFTOUT Dio,Clock,LSBFIRST,[noparse][[/noparse]190]
    SHIFTOUT Dio,Clock,LSBFIRST,[noparse][[/noparse] SECS, MINS,hrs]
    SHIFTOUT Dio,Clock,LSBFIRST,[noparse][[/noparse]date,month,day,year]
    SHIFTOUT Dio,Clock,LSBFIRST,[noparse][[/noparse]CTRL]
    LOW Rst
    RETURN

    GetClk:
    HIGH Rst
    SHIFTOUT Dio,Clock,LSBFIRST,[noparse][[/noparse]191]
    SHIFTIN Dio,Clock,LSBPRE,[noparse][[/noparse]secs,mins,hrs]
    SHIFTIN Dio,Clock,LSBPRE,[noparse][[/noparse]date,month,day,year]
    SHIFTIN Dio,Clock,LSBPRE,[noparse][[/noparse]CTRL]
    LOW Rst
    RETURN

    ShowTm:
    'IF secs = oldSc THEN EndST

    ST1:

    'FOR idx = 0 TO 2 ' get day name
    'Read (Day1+((day-1)*3)+idx), dyStr(idx)
    'NEXT

    SEROUT 16, N9600, [noparse][[/noparse]"Reading Time", cr]
    'SEROUT 16, N9600, [noparse][[/noparse]"Today is: ",str DYSTR\3," ",HEX2 MONTH,"/",HEX2 DATE,
    "/", HEX2 YEAR, " ", HEX2 HRS, ":", HEX2 MINS, ":", HEX2 SECS, CR]
    'serout 16, N9600, [noparse][[/noparse]hex2 month, "/", hex2 date, "/", hex2 year,cr, hex2 hrs,":",
    hex2 mins,":", hex2 secs, cr]
    pause 1

    serout 16, N9600, [noparse][[/noparse]hex2 hrs, ":",hex2 mins,":", hex2 secs, cr]
    pause 5000


    oldSc = SECS

    EndST:
    return




    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2003-03-05 22:12
    --- "M. E. M. Electronics" <memelectronics@e...>
    wrote:
    > Dear Larry,
    > i have used the clock chip in the past and the
    > code was cleared of some
    > bugs a long time ago when i couldn't get it to work
    > either. this was done
    > by Parallax. it works fine now. i will try and
    > find the floppy with the
    > code ASAP and post it for you. I also found that

    Mike,

    I too would be interested in that code, if you could
    upload it to the group, or e-mail off-group please.



    =====
    Chris Savage
    Knight Designs
    324 West Main Street
    Montour Falls, NY 14865
    (607) 535-6777

    http://www.knightdesigns.com

    __________________________________________________
    Do you Yahoo!?
    Yahoo! Tax Center - forms, calculators, tips, more
    http://taxes.yahoo.com/
  • ArchiverArchiver Posts: 46,084
    edited 2003-03-05 22:25
    will do. i will try and find the floppy tonight in the lab. hold tight at
    my age I am lucky if I find MY floppy, get it?
    mike m
    Original Message
    From: Chris Savage <knight_designs@y...>
    To: <basicstamps@yahoogroups.com>
    Sent: Wednesday, March 05, 2003 5:12 PM
    Subject: Re: [noparse][[/noparse]basicstamps] ---DS1302--- timekeeper help please


    > --- "M. E. M. Electronics" <memelectronics@e...>
    > wrote:
    > > Dear Larry,
    > > i have used the clock chip in the past and the
    > > code was cleared of some
    > > bugs a long time ago when i couldn't get it to work
    > > either. this was done
    > > by Parallax. it works fine now. i will try and
    > > find the floppy with the
    > > code ASAP and post it for you. I also found that
    >
    > Mike,
    >
    > I too would be interested in that code, if you could
    > upload it to the group, or e-mail off-group please.
    >
    >
    >
    > =====
    > Chris Savage
    > Knight Designs
    > 324 West Main Street
    > Montour Falls, NY 14865
    > (607) 535-6777
    >
    > http://www.knightdesigns.com
    >
    > __________________________________________________
    > Do you Yahoo!?
    > Yahoo! Tax Center - forms, calculators, tips, more
    > http://taxes.yahoo.com/
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2003-03-06 14:39
    Problem: DS1302 interfacing...

    OK, I've uploaded the version of the file which works
    for me. See the 'Files' section, 1302.bs2.
    I had a similar experience to yours -- I tried to use
    a program (as a tutorial) which simply didn't work.
    I then went to this program, which worked.

    Make sure you assign the pins at the start of the program
    to the three pins you're using for Data, Clock, and /Reset.
    Also, I have an LED on my board at pin 13 -- you may want
    to comment out the 'BlinkLED' call. Also, in order to
    set the chip you need to comment out the 'GOTO LOOP' which
    currently skips the time load section.

    The issues with the 1302 are how to write to the chip,
    how to read from the chip, and how to interpret the
    Binary Coded Decimal values read from the chip.
    See the code.


    --- In basicstamps@yahoogroups.com, "Lawrence Freeze"
    <forked_river@w...> wrote:
    > Allan,
    >
    > Thanks for the info. I made the change to 00, and unfortunatly got
    the same
    > result..
    >
    > Larry
    >
  • ArchiverArchiver Posts: 46,084
    edited 2003-03-07 01:11
    Thank you allan. I'll download it and give it a try.

    Larry
    Original Message
    From: "Allan Lane" <allan.lane@h...>
    To: <basicstamps@yahoogroups.com>
    Sent: Thursday, March 06, 2003 9:39 AM
    Subject: [noparse][[/noparse]basicstamps] Re: ---DS1302--- timekeeper help please


    > Problem: DS1302 interfacing...
    >
    > OK, I've uploaded the version of the file which works
    > for me. See the 'Files' section, 1302.bs2.
    > I had a similar experience to yours -- I tried to use
    > a program (as a tutorial) which simply didn't work.
    > I then went to this program, which worked.
    >
    > Make sure you assign the pins at the start of the program
    > to the three pins you're using for Data, Clock, and /Reset.
    > Also, I have an LED on my board at pin 13 -- you may want
    > to comment out the 'BlinkLED' call. Also, in order to
    > set the chip you need to comment out the 'GOTO LOOP' which
    > currently skips the time load section.
    >
    > The issues with the 1302 are how to write to the chip,
    > how to read from the chip, and how to interpret the
    > Binary Coded Decimal values read from the chip.
    > See the code.
    >
    >
    > --- In basicstamps@yahoogroups.com, "Lawrence Freeze"
    > <forked_river@w...> wrote:
    > > Allan,
    > >
    > > Thanks for the info. I made the change to 00, and unfortunatly got
    > the same
    > > result..
    > >
    > > Larry
    > >
    >
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    >
    >
Sign In or Register to comment.