Searching \ for 'fine-tuned delays (was Picstart 16b + A SNIPPET OF' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/time.htm?key=delay
Search entire site for: 'fine-tuned delays (was Picstart 16b + A SNIPPET OF'.

Truncated match.
PICList Thread
'fine-tuned delays (was Picstart 16b + A SNIPPET OF'
1998\08\24@083849 by wwl

picon face
>Speaking of which, I have been using a little piece of code when I have the extra ROM
>space.  I like it and I'll bet at least a couple of people will not have thought of
>it, even though it is hardly "rocket science."
>
>;****************************************************************************
>; SUBROUTINE:  DELAY4 thru DELAY25
>; delays of 4 to 25 clock cycles
>;****************************************************************************
>DELAY25
>        NOP
...etc...
>DELAY5
>        NOP
>DELAY4
>    RETLW       0
>
>Just an offering to try to refocus our attention back to PICs...

How about this -use  macro wait(n) to delay *any* amount from 0 to 255
cycles - for 16cxx but could easily be adapted for 5x

shortwait macro del
if (del>3) && (del<8)
call del7+(7-(del))
endif

if del <4
 if del>=2
 goto $+1
 endif
 if ((del) & 1) == 1
 nop
 endif
endif
endm

wait macro del  ; wait for (del) cycles)
if (del)<0
error 'negative delay'
endif
if (del)>=8
movlw ((del)-8) /4
call delay
shortwait ((del-8) % 4)
else
shortwait (del)
endif
endm

del7 goto del5  ; 7 cycle delay
del6 goto del4  ; 6 cycle delay
del5 nop           ; 5 cycle delay
del4 return      ; 4 cycle delay

delay
addlw 0ff
skpnc  goto delay
return

    ____                                                           ____
  _/ L_/  Mike Harrison / White Wing Logic / spam_OUTwwlTakeThisOuTspamnetcomuk.co.uk  _/ L_/
_/ W_/  Hardware & Software design / PCB Design / Consultancy  _/ W_/
/_W_/  Industrial / Computer Peripherals / Hazardous Area      /_W_/

More... (looser matching)
- Last day of these posts
- In 1998 , 1999 only
- Today
- New search...