Problem with code

MobileMe

Active Member
I'm trying to get some code to work and I'm getting some strange results.  I can get the board to send an email when the ACOFF function is called, but I'm not getting one when the ACON function is called.  The emails work when tested.  Anyone have any sugestions?
 



START
DELAY 5000
EMAIL EM1
LOOP:
TSTEQ IP1 0
CALLSUB ACON
TSTEQ IP1 1
CALLSUB ACOFF
GOTO LOOP
END
ACON:
ANDB RAM1 256 RAM2
TSTEQ 0 RAM2
SET RAM5 CTS
ORB RAM1 256 RAM1
SUB CTS RAM5 RAM7
TSTGT RAM7 2
GOTO ACRESTORE
TSTEQ 0 RAM2
CALLSUB RESET64
RET
ACRESTORE:
ANDB RAM1 512 RAM2
TSTEQ 0 RAM2
EMAIL EM3
ORB RAM1 512 RAM1
TSTEQ 0 RAM2
CALLSUB RESET128
RET
RESET64:
ANDB RAM1 64
BNZ SET64ZERO
RET
SET64ZERO:
XORB RAM1 64 RAM1
RET
RESET128:
ANDB RAM1 128
BNZ SET128
RET
SET128:
XORB RAM1 128 RAM1
RET
ACOFF:
ANDB RAM1 64 RAM2
TSTEQ 0 RAM2
SET RAM5 CTS
ORB RAM1 64 RAM1
SUB CTS RAM5 RAM7
TSTGT RAM7 2
GOTO ACFAIL
TSTEQ 0 RAM2
CALLSUB RESET256
RET
ACFAIL:
ANDB RAM1 128 RAM2
TSTEQ 0 RAM2
EMAIL EM2
ORB RAM1 128 RAM1
TSTEQ 0 RAM2
CALLSUB RESET512
RET
RESET256:
ANDB RAM1 256
BNZ SET256
RET
SET256:
XORB RAM1 256 RAM1
RET
RESET512:
ANDB RAM1 512
BNZ SET512
RET
SET512:
XORB RAM1 512 RAM1
RET

 


 
 
In your ACON, you have a line like
 

ORB RAM1 256 RAM1

 
What that is trying to do?  It seems you are using RAM1 bit position to keep the status flag. The above ORB result will be set in RAM1.
I would suggest to use VAR1 and VAR2 to substitute RAM1 and RAM2 during debugging, in that way, you can see what those variable values on screen, that can help debugging easier.
 
Back
Top