I received my PicKit2 a few weeks ago and I've been playing around with it. I'm having fun and learning alot. I should be able to complete one of my projects soon. However, I have a question, and be gentle, I'm new to this. One of the tutorials that came with the kit had the following program to make an LED blink:
#include <p16F690.inc>
__config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _BOR_OFF & _IESO_OFF & _FCMEN_OFF)
cblock 0x20
Delay1 ; Define two file registers for the
Delay2 ; delay loop
endc
org 0
Start:
bsf STATUS,RP0 ; select Register Page 1
bcf TRISC,0 ; make IO Pin B.0 an output
bcf STATUS,RP0 ; back to Register Page 0
MainLoop:
bsf PORTC,0 ; turn on LED C0
OndelayLoop:
decfsz Delay1,f ; Waste time.
goto OndelayLoop ; The Inner loop takes 3 instructions per loop * 256 loopss = 768 instructions
decfsz Delay2,f ; The outer loop takes and additional 3 instructions per lap * 256 loops
goto OndelayLoop ; (768+3) * 256 = 197376 instructions / 1M instructions per second = 0.197 sec.
; call it a two-tenths of a second.
bcf PORTC,0 ; Turn off LED C0
OffDelayLoop:
decfsz Delay1,f ; same delay as above
goto OffDelayLoop
decfsz Delay2,f
goto OffDelayLoop
goto MainLoop ; Do it again...
end
My question is concerning Delay1 and Delay2. No value was specified for them in the program, yet it says that the inner and outer loops occur 256 times each. Is it assumed that if no value is specified that the value will be 256? From Nigel's tutorials I know that one can specify values and change the delay, but this program doesn't do that.
#include <p16F690.inc>
__config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _BOR_OFF & _IESO_OFF & _FCMEN_OFF)
cblock 0x20
Delay1 ; Define two file registers for the
Delay2 ; delay loop
endc
org 0
Start:
bsf STATUS,RP0 ; select Register Page 1
bcf TRISC,0 ; make IO Pin B.0 an output
bcf STATUS,RP0 ; back to Register Page 0
MainLoop:
bsf PORTC,0 ; turn on LED C0
OndelayLoop:
decfsz Delay1,f ; Waste time.
goto OndelayLoop ; The Inner loop takes 3 instructions per loop * 256 loopss = 768 instructions
decfsz Delay2,f ; The outer loop takes and additional 3 instructions per lap * 256 loops
goto OndelayLoop ; (768+3) * 256 = 197376 instructions / 1M instructions per second = 0.197 sec.
; call it a two-tenths of a second.
bcf PORTC,0 ; Turn off LED C0
OffDelayLoop:
decfsz Delay1,f ; same delay as above
goto OffDelayLoop
decfsz Delay2,f
goto OffDelayLoop
goto MainLoop ; Do it again...
end
My question is concerning Delay1 and Delay2. No value was specified for them in the program, yet it says that the inner and outer loops occur 256 times each. Is it assumed that if no value is specified that the value will be 256? From Nigel's tutorials I know that one can specify values and change the delay, but this program doesn't do that.