OK, Maybe I see the problem. AND MAYBE I can explain it. Here goes. This is your program from a few posts back with some added comments:
Code:
TRISA = $FF 'Postavi sve pinove porta A kao ulazne
TRISB = $00 'Postavi sve pinove porta B kao izlazne
B0 var byte
i var byte
symbol t1 = porta.1
symbol tajmer = portb.0
symbol rele = porta.0
begin:
pause 100 'vrlo bitna pauza'
while tajmer = 1 and rele = 1 ' when both are 1, we do this while loop
goto petlja
petlja:
i = 0
for i = 1 to 2
If i = 1 then
pause 300
goto petlja1' EVERY time timer and relay are 1, we go to petlja1
endif
if i = 2 then
pause 300
goto petlja2
endif
next i
petlja1: ' We are here because timer and relay are = 1
PAUSE 500
tajmer = 0 'iskljuci tajmer' ' now timer = 0?
portRETb.1 = 0 'ukljuci crvenu diodu veliku'
pause 3000 'pauza 3 sekunde'
RETURN ' I think you need to add this here
petlja2: ' We are here because we fall in here from petlja1
tajmer = 1 ' now timer = 1 again
portb.2 = 0 'ukljuci diodu zelenu'
portb.1 = 1 'iskljuci crvenu diodu'
pause 200
RETURN' and here
wend 'vrlo bitna pauza' ' go back and check while again. right now timer = 1, relay = ??
' If relay also = 1, you will never get out of the loop.
IF tajmer = 1 AND rele = 1 ' I think you will never get to this check, stuck in the while loop.
portb.3 = 0
portb.1 = 1
portb.2 = 1
ENDIF
B0 = 0
button t1,0,255,0,B0,1,ukljucenje 'ako je taster pritisnut idi na ukljucenje'
goto begin
ukljucenje:
tajmer = 1
goto begin
End
If you change the RED goto to gosub,add the returns, and move the petlja1 and petlja2 routines to the end of the program. It may act as you expect.
Bookmarks