BS2 on BOE does not run after power off
dartec
Posts: 6
I use a BS2 on a BOE board. I also have an eb600 bluetooth and a RFID both Parallax boards. When I power the board OFF and power back ON, I have to do either of two things to get the original program to run properly:
a) to push the reset button on the board
b) to reload the BS2 program.
My application requires that the program run flawlessly after power OFF and power back ON (no reload of the program).
Can anybody help?
Angel
a) to push the reset button on the board
b) to reload the BS2 program.
My application requires that the program run flawlessly after power OFF and power back ON (no reload of the program).
Can anybody help?
Angel
Comments
-Phil
'****************RKA4 V3 SHORT. Rev2
'*****Author:Angel Diez, March 2008
'**********************************
'{$STAMP BS2}
'{$PBASIC 2.5}
'{$PORT COM1}
' constant declarations
nbrCount CON 1
' variable declarations
packet VAR Byte(15)
targetNbr VAR Byte
i VAR Byte
j VAR Byte
Enable PIN 9 ' low = reader on
RFINPUT PIN 10 ' serial from reader
Latch PIN 12 ' lock/latch control
'Spkr PIN 11 ' speaker output
'TmAdj CON $100 ' x 1.0 (time adjust)
'FrAdj CON $100 ' x 1.0 (freq adjust)
'
[ Constants ]
idx VAR Byte ' tag byte index
'
[ EEPROM Data ]
' data
DATA $00, $0C, $84, $00, $75, $D4 ' node A (TSA1)
'
[ Initialization ]
Reset:
LOW Latch ' lock the door!
'RFID Reader Module
'
[ Program Code ]
Main:
LOW Enable ' activate the reader
SERIN RFINPUT, 396, [WAIT($0A), STR packet\10] ' wait for hdr + ID
HIGH Enable ' deactivate reader
'HIGH Latch ' remove latch
'FREQOUT Spkr, 2000 */ TmAdj, 880 */ FrAdj ' beep
'LOW Latch ' restore latch
'GOSUB Bmain
'END
'
[ Subroutines ]
' initialise the eb500
GOSUB eb500Init
' generate a packet
GOSUB generatePacket
GOTO Main
END
' eb500 initialisation subroutine
eb500Init:
' wait for the eb500 radio to be ready
' switch to command mode
LOW 6
PAUSE 200
' disconnect (if necessary)
'SEROUT 1, 84, ["dis", CR]
'SERIN 0, 84, [WAIT(CR, ">")]
'DEBUG "done.", CR
RETURN
' connection polling subroutine
connectionWait:
IF (IN5 = 1) THEN connectionWait
RETURN
' disconnection polling subroutine
disconnectionWait:
IF (IN5 = 0) THEN disconnectionWait
RETURN
' disconnection from data mode subroutine
'disconnectFromDataMode:
' switch to command mode
'LOW 6
'SERIN 0, 84, [WAIT(CR, ">")]
' disconnect
'SEROUT 1, 84, ["dis", CR]
'SERIN 0, 84, [WAIT(CR, ">")]
'RETURN
' packet routing subroutine
routePacket:
' compute target neighbour
targetNbr = packet(0) // nbrCount
' modify the packet
packet(0) = packet(0) / nbrCount
packet(1) = packet(1) - 1
' connect to targetNbr
GOSUB targetNbrConnect
PAUSE 200
' route the packet
SEROUT 1, 84, [STR packet\15]
'DEBUG "ROUTE=", HEX2 packet(0)
' wait for disconnection
GOSUB disconnectionWait
RETURN
' target neighbour connection subroutine
targetNbrConnect:
' send the connection command
SEROUT 1, 84, ["con "]
'DEBUG "target", HEX2 targetNbr
' send the hardware address
FOR i = 0 TO 5
READ (targetNbr * 6 + i), j
SEROUT 1, 84, [HEX2 j]
'DEBUG HEX2 j,":"
IF (i <> 5) THEN SEROUT 1, 84, [":"]
NEXT
' connect
SEROUT 1, 84, [CR]
'SERIN 0, 84, [WAIT(CR, ">")]
GOSUB connectionWait
' wait for the neighbour to be ready
'PAUSE 400
RETURN
' packet generator subroutine (DEBUG PURPOSES ONLY)
generatePacket:
' copy the packet data
FOR idx = 12 TO 3
packet(idx)=packet(idx-3)
'DEBUG "P", HEX2 packet(idx)
NEXT
packet(0) = 0 '**** RTE = 0 (server)
packet(1) = 0 '**** TTL = 0
packet(2) = 255 '*** sync
packet(13) = CR
packet(14) = LF
GOSUB routePacket
RETURN
The connections are as per eb600 and RFID board specs (both serial input and output)
-Phil