I had a similar problem when moving from 16F to 18F. Finally I discovered it was a STACK OVERFLOW reset. The 16F does not care if you overflow the stack, but the 18F does!
If you call a subroutine (GOSUB) and you do not RETURN from that subroutine, because of a GOTO or IF-THEN or TimeOut within the subroutine (looks like you have them), then the last address PUSHed onto the stack does not get POPped from the stack and it eventually overflows causing a reset.
If you exit the subroutine without a RETURN, then you must manually POP the stack. (I also use the STKPTR = 0 in some parts of the program, though I know this is cheating a bit).
So... anytime you are exiting a subroutine early (not using Return) you should POP the stack:
@ POP
On the 16F you can keep pushing onto the stack with no problems, so you never see the problem until you move to an 18F chip.
I'm sure someone else here can provide a more detailed (accurate?) explanation of the 18F stack pointer, but I hope this at least helps you in the right direction.
Jim




Bookmarks