Good Morning

I am having a problem with the process hanging after 10 record cycles. Toggling the CYCLE switch does not get it running again. It hangs in the "not recording" mode every time.

So I whittled the program down to bare bones and played with the 20000 number. Replacing that with 3000, 6000, 10000 or 20000 very repeatedly makes it hang after 10 record cycles. Any ideas? Code follows:

' Name : SHORT CYCLE.pbp
' Compiler : PICBASIC PRO Compiler 3.1.6.2
' Assembler : PM or MPASM
' Target PIC : 12F types
' Hardware : PIC12F683
' Oscillator : internal



#CONFIG
__config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF
#ENDCONFIG


CLEAR
DEFINE OSC 4
ANSEL = 0
CMCON0 = 7


RECPB var GPIO.4 ' Assign name "RECPB" to GPIO 4 OUTPUT
CYCLE var GPIO.0 ' Assign name "CYCLE" to GPIO 0 INPUT


j var word ' timing loop count for 3sec record timing
k var word ' timing loop count for 57sec wait timing


Mainloop:


if CYCLE = 0 then goto Mainloop ' do not do any recording
if cycle = 1 then gosub recording ' do the 3/57 record cycle

Recording:
low RECPB ' Low Rec PB to start recording
Pause 500 ' start recording for 3 seconds
high RECPB ' High Rec PB after recording start
for j = 1 to 3000 ' Loop count for rec timing
pause 1
next j
low RECPB ' Low Rec PB to stop recording
Pause 500 ' Stop recording after 3 seconds
high RECPB ' High Rec PB after recording Stop
for k = 1 to 20000 ' **Pause for 57 seconds and repeat cycle.
pause 1 '
next k
return

goto mainloop

End