'{$STAMP BS2} 'STAMP directive (specifies a BS2) ' Simple ACCESS.bus watchdog for Zaza the robot. ' ' Brian Rudy (brudyNO@SPAMpraecogito.com) ' ' ' v0.02 6/4/2004 ' Added support for data line polling and command list dump. ' ' v0.01 5/28/2004 ' First working version ' ' Port configuration ' 0 - NC ' 1 - NC ' 2 - NC ' 3 - NC ' 4 - NC ' 5 - NC ' 6 - NC ' 7 - NC ' 8 - Reset, active high, driven through TIL111 ' 9 - A.bus SDA, buffered through 74ALS244 ' 10 - A.bus SCL, buffered through 74ALS244 ' 11 - NC ' 12 - NC ' 13 - NC ' 14 - NC ' 15 - NC ' Ab_reset con 8 Ab_SDA con 9 Ab_SCL con 10 Pwidth VAR WORD Command VAR BYTE DIRS = %0000000100000000 'set all but port 8 to inputs main: serout 16,16468,["Watchdog ready:",CR,10] ' inverted 9600 n,8,1 serin 16,16468,[Command] if Command = 99 Then check_heartbeat_cl ' c command if Command = 100 Then check_heartbeat_da ' d command if Command = 114 Then reset_bus ' r command serout 16,16468,["Commands: c(clock heartbeat),d(data heartbeat),r(reset ACCESS.bus)",CR,10] ' inverted 9600 n,8,1 goto main check_heartbeat_cl: pulsin Ab_SCL,0,Pwidth if Pwidth = 0 Then bus_hung serout 16,16468,["SCL=",DEC Pwidth,CR,10] ' inverted 9600 n,8,1 goto main check_heartbeat_da: pulsin Ab_SDA,0,Pwidth if Pwidth = 0 Then bus_hung serout 16,16468,["SDA=",DEC Pwidth,CR,10] ' inverted 9600 n,8,1 goto main bus_hung: 'Debug "ACCESS.bus is hung!", CR serout 16,16468,["Hung!",CR,10] ' inverted 9600 n,8,1 goto main reset_bus: high Ab_reset pause 2000 ' wait two seconds low Ab_reset serout 16,16468,["Bus reset",CR,10] ' inverted 9600 n,8,1 goto main