Shop OBEX P1 Docs P2 Docs Learn Events
Clock Chip Help — Parallax Forums

Clock Chip Help

Tom PTom P Posts: 97
edited 2008-04-03 17:33 in BASIC Stamp
Please help!!

I'am trying to experiment/run the first two clock programs in the DS 1302 AppKit buth neither program will work.
I get a message ---- loop must be preceeded by DO'. I assume this is problem which came about with new STAMP editor.
How do I modify this program to work with new editor!!
thanks


'***************************************************************************
'* 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 = $98
RTCCmd = YrReg
GOSUB WriteRTC
Temp = $08
RTCCmd = MonReg
GOSUB WriteRTC
Temp = $27
RTCCmd = DateReg
GOSUB WriteRTC
Temp = $48
RTCCmd = MinReg
GOSUB WriteRTC
Temp = $00
RTCCmd = SecReg
GOSUB WriteRTC
Temp = $80
RTCCmd = CtrlReg
GOSUB WriteRTC
Loop:
GOSUB ReadRTCBurst
DEBUG HOME,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
GOTO Loop
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

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2008-04-03 13:24
    Tom -

    You should insert the following two lines at the very beginning of your program:

    ' {$STAMP 2} Indicate the PBASIC Stamp Model Number
    ' {$PBASIC 2.5} Indicate the PBASIC Tokenizer Level

    Your evaluation of the problem is 100% correct!

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Involvement and committment can be best understood by looking at a plate of ham and eggs. The chicken was involved, but the pig was committed. ANON
  • Tom PTom P Posts: 97
    edited 2008-04-03 16:54
    I have added the '{$STAMP 2} and the {PBASIC 2.5} lines to the top of the clock programs but the problem still persists in that
    I still get an error message stating ---- loop must be preceeded by DO'.
    So, there is still a problem in that the programs will not run?
    Andy ideas still have modify this program to work !
    thanks
  • stamptrolstamptrol Posts: 1,731
    edited 2008-04-03 16:58
    You're trying to use "Loop" as a label. Because DO and LOOP are part of the Stamp command set, you must choose another word to use as your label.

    Cheers,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-04-03 17:33
    Better yet, try the following Demo Code for the DS1302. There’s even a template for making your own programs.

    http://forums.parallax.com/forums/default.aspx?f=21&p=4&x=25&ord=ld

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
Sign In or Register to comment.