BS-2 VS BS-2p program & Pocket Watch B
MaxiOmega
Posts: 10
My program works great on my BS-2 for my Pocket Watch B chip. When I Change the chip to a BS-2p the program returns an error. How can I correct this, so I can use my BS-2p40 with the Pocket Watch B.
Here is my current program:
'{$STAMP BS2p}
' {$PBASIC 2.5}
'Set I/O pin directions
INPUT· 2 'communication FROM Pocket Watch B
OUTPUT 1 'communication TO Pocket Watch B
INPUT· 0 'ALARM monitoring pin
'Declare variables
ss VAR Byte 'seconds
mm VAR Byte 'minutes
hh VAR Byte 'hours
dd VAR Byte 'days
mo VAR Byte 'months
yl VAR Byte 'years low
yh VAR Byte 'years high
Begin:
HIGH 1 'ensure no spurious start bit
PAUSE 2000
SetTimeCommand: 'set TO 12:30PM April 23, 2005
SEROUT 1,84,[noparse][[/noparse]85,16,20,41,21,28,05,05]
PAUSE 100
SetAlarmCommand: 'set to 15 seconds after time
SEROUT 1,84,[noparse][[/noparse]85,17,00,55,17,28,05,05]
PAUSE 100
ReadTimeCommand: 'see what time it is presently
SEROUT 1,188,[noparse][[/noparse]85,2]
SERIN 2,188,5000,BadLoop1,[noparse][[/noparse]ss,mm,hh,dd,mo,yl ]
IF hh >12 THEN PM
DEBUG "Time:··· ",DEC2 hh,":",DEC2 mm ,":",DEC2 ss," AM····· ",DEC2 mo,"/",DEC2 dd, "/", DEC2 yl, CR
GOTO cont
PM:
DEBUG "Time:··· ",DEC2 hh- 12,":",DEC2 mm ,":",DEC2 ss," PM····· ",DEC2 mo,"/",DEC2 dd, "/", DEC2 yl, CR
cont:
PAUSE 600
GOTO ReadTimeCommand
ReadAlarmCommand: 'see what time alarm set to go off
SEROUT 1,84,[noparse][[/noparse]85,3]
SERIN 2,84,5000,BadAlarm1,[noparse][[/noparse] mm,hh,ss,dd,mo,yl ]
DEBUG "Alarm: ",DEC2 hh,":",DEC2 mm,":",DEC2 ss," ",DEC2 mo,"/",DEC2 dd, "/", DEC2 yl, CR
Done:
DEBUG CR,CR,"Done with AN-501"
DoneLoop:
GOTO DoneLoop
BadAlarm1:
DEBUG "Alarm read 1 bad",CR
GOTO ReadAlarmCommand
BadLoop1:
DEBUG "Loop1 error", CR
GOTO DoneLoop
Here is my current program:
'{$STAMP BS2p}
' {$PBASIC 2.5}
'Set I/O pin directions
INPUT· 2 'communication FROM Pocket Watch B
OUTPUT 1 'communication TO Pocket Watch B
INPUT· 0 'ALARM monitoring pin
'Declare variables
ss VAR Byte 'seconds
mm VAR Byte 'minutes
hh VAR Byte 'hours
dd VAR Byte 'days
mo VAR Byte 'months
yl VAR Byte 'years low
yh VAR Byte 'years high
Begin:
HIGH 1 'ensure no spurious start bit
PAUSE 2000
SetTimeCommand: 'set TO 12:30PM April 23, 2005
SEROUT 1,84,[noparse][[/noparse]85,16,20,41,21,28,05,05]
PAUSE 100
SetAlarmCommand: 'set to 15 seconds after time
SEROUT 1,84,[noparse][[/noparse]85,17,00,55,17,28,05,05]
PAUSE 100
ReadTimeCommand: 'see what time it is presently
SEROUT 1,188,[noparse][[/noparse]85,2]
SERIN 2,188,5000,BadLoop1,[noparse][[/noparse]ss,mm,hh,dd,mo,yl ]
IF hh >12 THEN PM
DEBUG "Time:··· ",DEC2 hh,":",DEC2 mm ,":",DEC2 ss," AM····· ",DEC2 mo,"/",DEC2 dd, "/", DEC2 yl, CR
GOTO cont
PM:
DEBUG "Time:··· ",DEC2 hh- 12,":",DEC2 mm ,":",DEC2 ss," PM····· ",DEC2 mo,"/",DEC2 dd, "/", DEC2 yl, CR
cont:
PAUSE 600
GOTO ReadTimeCommand
ReadAlarmCommand: 'see what time alarm set to go off
SEROUT 1,84,[noparse][[/noparse]85,3]
SERIN 2,84,5000,BadAlarm1,[noparse][[/noparse] mm,hh,ss,dd,mo,yl ]
DEBUG "Alarm: ",DEC2 hh,":",DEC2 mm,":",DEC2 ss," ",DEC2 mo,"/",DEC2 dd, "/", DEC2 yl, CR
Done:
DEBUG CR,CR,"Done with AN-501"
DoneLoop:
GOTO DoneLoop
BadAlarm1:
DEBUG "Alarm read 1 bad",CR
GOTO ReadAlarmCommand
BadLoop1:
DEBUG "Loop1 error", CR
GOTO DoneLoop
Comments
Chris
#SELECT $STAMP
· #CASE BS2, BS2E, BS2PE
··· T1200······ CON···· 813
··· T2400······ CON···· 396
··· T4800······ CON···· 188
··· T9600······ CON···· 84
··· T19K2······ CON···· 32
··· TMidi······ CON···· 12
··· T38K4······ CON···· 6
· #CASE BS2SX, BS2P
··· T1200······ CON···· 2063
··· T2400······ CON···· 1021
··· T4800······ CON···· 500
··· T9600······ CON···· 240
··· T19K2······ CON···· 110
··· TMidi······ CON···· 60
··· T38K4······ CON···· 45
· #CASE BS2PX
··· T1200······ CON···· 3313
··· T2400······ CON···· 1646
··· T4800······ CON···· 813
··· T9600······ CON···· 396
··· T19K2······ CON···· 188
··· TMidi······ CON···· 108
··· T38K4······ CON···· 84
#ENDSELECT
SevenBit······· CON···· $2000
Inverted······· CON···· $4000
Open··········· CON···· $8000
Baud··········· CON···· T9600
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Thanks for your help.
·