Fredrick
- 10th January 2008, 19:36
Today i buyed PICBASIC Pro and made the first test program whit a PIC16F872
But when i use the code below the pic stops or hangs sometimes the (LEDīs stop flashing) when i press the button (PORTB.0) but whit code number 2 it works fine..
Why?
ADCON1 = 7
i var word
loop:
High PORTA.0
High PORTA.1
for i = 1 to 30
Pause 10
IF PORTB.0 = 1 then GOSUB but
next i
Low PORTA.0
Low PORTA.1
for i = 1 to 30
Pause 10
IF PORTB.0 = 1 then GOSUB but
next i
Goto loop
but:
high PORTA.2
pause 1000
low PORTA.2
RETURN
Code numer 2
ADCON1 = 7
i var word
loop:
High PORTA.0
High PORTA.1
for i = 1 to 30
Pause 10
IF PORTB.0 = 1 then but
next i
Low PORTA.0
Low PORTA.1
for i = 1 to 30
Pause 10
IF PORTB.0 = 1 then but
next i
Goto loop
but:
high PORTA.2
pause 1000
low PORTA.2
goto loop
But when i use the code below the pic stops or hangs sometimes the (LEDīs stop flashing) when i press the button (PORTB.0) but whit code number 2 it works fine..
Why?
ADCON1 = 7
i var word
loop:
High PORTA.0
High PORTA.1
for i = 1 to 30
Pause 10
IF PORTB.0 = 1 then GOSUB but
next i
Low PORTA.0
Low PORTA.1
for i = 1 to 30
Pause 10
IF PORTB.0 = 1 then GOSUB but
next i
Goto loop
but:
high PORTA.2
pause 1000
low PORTA.2
RETURN
Code numer 2
ADCON1 = 7
i var word
loop:
High PORTA.0
High PORTA.1
for i = 1 to 30
Pause 10
IF PORTB.0 = 1 then but
next i
Low PORTA.0
Low PORTA.1
for i = 1 to 30
Pause 10
IF PORTB.0 = 1 then but
next i
Goto loop
but:
high PORTA.2
pause 1000
low PORTA.2
goto loop