16f877 delay subroutines...

Started by German Enred September 27, 2003

Hi:

I'm working on delays subroutines in my prog. Can someone verify if this
delays "concepts" are OK?

;Delay
; ***************************** Delay subroutine retardo movlw .158
; - 1 (1 machine cycle)
movwf cont1 ; | 1 ...
buc_2 movlw .83 ; | k movwf cont2 ; | k
gamma decfsz cont2,F ; | (j-1)*k
goto gamma ; | 2*(j-1)*k
nop ; k
decfsz cont1,F ; | (k-1) goto buc_2 ; | 2*(k-1)
return ; - 2

The final sum give = 1 + 1 + k + k + (j-1)*k + 2*(j-1)*k + k + (k-1) +
2*(k-1) + 2 = 1+3*k(j+1)

Were:

k = loops of the first loop (master or primary = 158)
j = loops of the second loop (slave = 83) Germ Herndez C.