PDA

View Full Version : Simple Blinking LED - WTF!!



johnnylynx
- 1st February 2010, 05:17
OK, I've been out of the PIC stuff for about a year now and have noticed some significant brain drain (on my behalf):)

I am just trying to get back into the PICbasic with some simple LED blinking with a 12F683. I looked at some of my old code with controlled 3 LED's and the code (compiled) works just fine. But when I comment out 2 of the 3 LED's, the remaining LED just stays ON.

The code posted shows only GPIO.1 remaining active...but the LED stays on.

I know this is peanuts to all of you...but please help me out. I even tried a simple code with a simple loop! Still didn't work.

John.


osccon = %01100000 ' Ocs set to 4 MHz
trisio = %00000000 '
wpu = %00011000
'CMCON0 = 7 ' Analog comparators off
'ANSEL = 0 ' Analog select set to digital, pg 69 data
'ADCON0 = 0 ' A/D turned OFF, pg 68 of data




pausetime var word
Out0 var gpio.0
Out1 var gpio.1
Out2 var gpio.2
B0 var byte

' SET VARIABLES
pausetime = 200
B0 = 0
low 0
low 1
low 2


start:

'button gpio.3,1,10,5,B0,1,notp
if gpio.3 = 1 then goto start

'call blink0
'call blink2
call blink1


goto start


blink0:
high out0
pause pausetime
low out0
'pause pausetime
return

blink1:
high out1
pause pausetime
low out1
'pause pausetime
return

blink2:
high out2
pause pausetime
low out2
'pause pausetime
return

notp:
goto start

end

Archangel
- 1st February 2010, 05:20
Hi johnnylynx,
Change CALL to GoSub
Call is an asm function - return works with gosub.

johnnylynx
- 1st February 2010, 05:34
Hi johnnylynx,
Change CALL to GoSub
Call is an asm function - return works with gosub.

Hi,

Thanks for the quick feedback - Question though - why would it work if all three or two CALL lines are active?

I tried changing the CALL to GOSUB and it still didn't work. If I add a 'PAUSE pausetime' after the LOW command it worked. Found that solution elsewhere!

Why would it work with out the added PAUSE (with 2 or more CALL's active)?

Confused I am.

John.

Archangel
- 1st February 2010, 05:39
Hi,

Thanks for the quick feedback - Question though - why would it work if all three or two CALL lines are active?

I tried changing the CALL to GOSUB and it still didn't work. If I add a 'PAUSE pausetime' after the LOW command it worked. Found that solution elsewhere!

Why would it work with out the added PAUSE (with 2 or more CALL's active)?

Confused I am.

John.Hi John,
Think about what you are telling it to do,
Turn light on
pause 200
turn light off
no waiting here
turn light on
pause . . . The PIC is faster than the eye.

johnnylynx
- 1st February 2010, 05:59
Hi John,
Think about what you are telling it to do,
Turn light on
pause 200
turn light off
no waiting here
turn light on
pause . . . The PIC is faster than the eye.

Yep, time for me to get some rest...Can't believe I missed that. Now I can rest peacefully.

Thanks!

GatorGuy
- 1st February 2010, 06:19
Don't feel bad, I looked over it and didn't see that either! haha.