This is example from manual on Parallel tasking......
It has 2 tasks, flash a led to show system is on and then if it goes into alarm when the input is high, but it stays in alarm loop and doesn't reset when input is low.
start0:
pause 5000
high B.1
pause 500
low B.1
goto start0
start1:
if pinC.2 = 1 then alarm
goto start1
alarm:
high B.3
goto alarm
................................................................
Below is same prog with the pin numbers changes to suit my spare pins but works the same, except I tried to add an extra task to control the resetting of the alarm when the input went low again........ but it doesn't reset, it stays in alarm when input low again.
I basically added another "allclear" task copying how the alarm task was setup.
The original had loop goto alarm at the bottom when in alarm so I did same for allclear. Hoping the alarm would clear after 2 seconds of holding the input low. but didn't work.... stayed in alarm. I changed the goto alarm and goto allclear to returns, it now resets when input is low but the alarm LED gives a short flash along with the "heartbeat" instead of the heartbeat giving a slow 5 sec flash.
So what is proper way to add extra tasks and also what about the "init" or setup at the top of a program. The compiler want "start0" to be the 1st line even when the 1st task may not start until various variables etc are setup....??
start0:
pause 5000
high B.0
pause 500
low B.0
goto start0
start1:
if pinC.6 = 1 then alarm
goto start1
start2:
if pinC.6 = 0 then allclear
goto start2
alarm:
high C.7
goto alarm
allclear:
pause 1000
if pinC.6 = 0 then
low C.7
end if
pause 1000
goto allclear
...............................................................................
It has 2 tasks, flash a led to show system is on and then if it goes into alarm when the input is high, but it stays in alarm loop and doesn't reset when input is low.
start0:
pause 5000
high B.1
pause 500
low B.1
goto start0
start1:
if pinC.2 = 1 then alarm
goto start1
alarm:
high B.3
goto alarm
................................................................
Below is same prog with the pin numbers changes to suit my spare pins but works the same, except I tried to add an extra task to control the resetting of the alarm when the input went low again........ but it doesn't reset, it stays in alarm when input low again.
I basically added another "allclear" task copying how the alarm task was setup.
The original had loop goto alarm at the bottom when in alarm so I did same for allclear. Hoping the alarm would clear after 2 seconds of holding the input low. but didn't work.... stayed in alarm. I changed the goto alarm and goto allclear to returns, it now resets when input is low but the alarm LED gives a short flash along with the "heartbeat" instead of the heartbeat giving a slow 5 sec flash.
So what is proper way to add extra tasks and also what about the "init" or setup at the top of a program. The compiler want "start0" to be the 1st line even when the 1st task may not start until various variables etc are setup....??
start0:
pause 5000
high B.0
pause 500
low B.0
goto start0
start1:
if pinC.6 = 1 then alarm
goto start1
start2:
if pinC.6 = 0 then allclear
goto start2
alarm:
high C.7
goto alarm
allclear:
pause 1000
if pinC.6 = 0 then
low C.7
end if
pause 1000
goto allclear
...............................................................................