Hi guys and girls - a newbie here.
Just got into PIC programming to fulfill the needs of a few small projects im working on.
Here I am trying to get a PIC to continuously switch an LED on for 20secs, and then off for 20secs...
I am having a few problems with the delay loop. It seems to work when the interval is 1sec (i.e. 1sec on, 1 sec off) - but when the variables (d1, d2, d3) within the loop are changed to give 20sec, my LED just comes on and stays on?
Prehaps im going the wrong way about things or i've made a newbie error...
Anyone have any ideas?
Here is the code:
Thanks in advance for help...
Rob
Just got into PIC programming to fulfill the needs of a few small projects im working on.
Here I am trying to get a PIC to continuously switch an LED on for 20secs, and then off for 20secs...
I am having a few problems with the delay loop. It seems to work when the interval is 1sec (i.e. 1sec on, 1 sec off) - but when the variables (d1, d2, d3) within the loop are changed to give 20sec, my LED just comes on and stays on?
Prehaps im going the wrong way about things or i've made a newbie error...
Anyone have any ideas?
Here is the code:
list p=16F84A
#include <p16F84A.inc>
main
STATUS equ h'03'
TRISA equ h'85'
PORTA equ h'05'
BSF STATUS,5
MOVLW h'00'
MOVWF TRISA
BCF STATUS,5
Start
Call LEDOn
Call Delay1
Call LEDOff
Call Delay1
goto Start
LEDOnMOVLW h'1f'
MOVWF PORTA
return
LEDOff
MOVLW h'00'
MOVWF PORTA
return
;*****Delay1 - SUB*****
cblock 0x0C
d1
d2
d3
endc
Delay1
movlw 0x07Delay1_0
movwf d1
movlw 0x2F
movwf d2
movlw 0x03
movwf d3
decfsz d1, f
goto $+2
decfsz d2, f
goto $+2
decfsz d3, f
goto Delay1_0
goto $+1
goto $+1
goto $+1
return
END
Thanks in advance for help...
Rob