Think you are using Assembly, yes, for a long delay, it is not easy to calculate the proper delay loop. With PIC16F84, we have the other way is using interrupt, but it is not really easy for beginner either.
Using delay loop in assembly, we can get the most accurate time delay, but that keeps the CPU always busy.
Fortunately, Mr. Boucher provides PIC people with his excellent freeware for calculating delay loop for PICs, you can download the software of only 2MB from the link:
www.mnsi.net/~boucher/picloops.html
Using this software, you can "trim" the loop, or see how to trim the code, to get the best solution for your project.
This is the calculation result from this software:
;PIC Time Delay = 0,9999990 s with 999,999 machine cycles, Osc = 4 MHz include Call + return.
movlw D'6'
movwf CounterC
movlw D'24'
movwf CounterB
movlw D'167'
movwf CounterA
loop decfsz CounterA,1
goto loop
decfsz CounterB,1
goto loop
decfsz CounterC,1
goto loop
return
If you set Counter A = 168, then the delay will = 1.0000020 s with 1,000,002 machine cycles.
Good luck and Happy programming.
nguyennam
===========================
thanks for help!
unfortunately, i still cannot comprehend how to solve this example.:?:
can you help me in solving that delay subroutine?.. :!: