Thanks for the help so far.
I disabled the stack overflow reset and indeed the program stops working after 28 times. It looks like a stack overflow to me. This is the code I used:
How could I change it, so it works on an 18F?
Include "modedefs.bas"
DEFINE OSC 20 ' Set Xtal freq.
DEFINE DEBUG_REG PORTD ' Set Debug pin port
DEFINE DEBUG_BIT 4 ' Set Debug pin bit
DEFINE DEBUG_BAUD 9600 ' Set Debug baud rate
DEFINE DEBUG_MODE 1 ' Set Debug mode: 0 = true, 1 = inverted
Timeout VAR BYTE
Pushbutton VAR BYTE
Startup:
DEBUG 10,13,10,13," !!! Startup !!!!",13,10,13,10
goto Main
Main:
Pushbutton = 1 ' Usually 'Pushbutton' is an input-pin
IF Pushbutton = 1 THEN
GOTO FunctionD ' If the pushbutton is pushed execute FunctionD
ENDIF
GOTO Main
FunctionD:
GOSUB Timeout2
DEBUG "Function D",10,13
' Execute some function
GOTO FunctionD
Timeout2:
PAUSE 100
Timeout = Timeout + 1
IF Timeout > 4 THEN
DEBUG 10,13,"Timeout",10,13
Timeout = 0
GOTO Main ' Timeout occured -> go back to Main
ENDIF
RETURN
END
Bookmarks