1 out of 1 members found this post helpful.
Did you find this post helpful?

|
Re: Why would this simple code hang after 10 cycles:
Not sure to be honest...
How is the switch wired? Pin to GND with pullup or pin to Vdd with pulldown?
Give this a try:
Code:
DEFINE OSC 4
RECPB var GPIO.4 ' Assign name "RECPB" to GPIO 4 OUTPUT
CYCLE var GPIO.0 ' Assign name "CYCLE" to GPIO 0 INPUT
TRISIO.4 = 0 ' GPIO.4 as output
ANSEL = 0
CMCON0 = 7
OPTION_REG.7 = 0 ' Enable individual pullups
WPU.0 = 1 ' Enable weak pullup on GPIO.0
Mainloop:
IF Cycle = 1 THEN ' do the 3/57 record cycle
RECPB = 0 ' Low Rec PB to start recording
Pause 500 ' start recording for 3 seconds
RECPB = 1 ' High Rec PB after recording start
PAUSE 3000
RECPB = 0 ' Low Rec PB to stop recording
Pause 500 ' Stop recording after 3 seconds
RECPB = 1 ' High Rec PB after recording Stop
PAUSE 10000
ENDIF
GOTO Mainloop
End
Bookmarks