Hello Everybody. I am bringing up this subject again because on several occasions, my code would be much simpler using a GOSUB that contains a GOTO. However, I was told that not cancelling a GOSUB will cause code failure at some point. I've got an idea that I'm wondering if it would work. Tie MCLR to a port pin. Make the port pin an input. Both pins are tied to B+ through a resistor. In the code where the the GOTO is inside a GOSUB, make that port pin output low. It seems to me that this would reset the PIC and cancel the gosub. Am I correct? Example with 12F629 GPIO.3 (MCLR) attached to GPIO.4. Both tied to B+ through 10K:
BOOTUP:
CMCON = 7 'comparators off
TRISIO = %11111111 'ALL INPUTS
DEFINE OSCCAL_1K 1 ' Set OSCCAL for 1K device
@ DEVICE MCLR_ON, INTRC_OSC, WDT_ON, BOD_ON, PWRT_ON, PROTECT_ON
PAUSE 500 'SETTLE DOWN
START:
DO THIS AND THAT
GOSUB CHECKSWITCH
GOTO START
CHECKSWITCH:
IF GPIO.0 = 1 THEN RETURN
LOW GPIO.4 'WILL THIS CANCEL GOSUB & SEND TO BOOTUP??
Bookmarks