PIC Microcontoller Delay Method

Stack Recursive Delay

The name of the lable you call indicates the number of cycles (Convert cycles to time) that will be executed before returning. This uses an amazingly small number of bytes and is probably more effecient than inline loops or nop's if you are going a lot of little delays of varying times through out your code.

Delay131072 call Delay16384	; uses 6 stack levels
Delay114688 call Delay16384
Delay98304 call Delay16384
Delay81920 call Delay16384
Delay65536 call Delay16384
Delay49152 call Delay16384
Delay32768 call Delay16384
Delay16384 call Delay2048	;uses 5 stack levels
Delay14336 call Delay2048
Delay12288 call Delay2048
Delay10240 call Delay2048
Delay8192 call Delay2048
Delay6144 call Delay2048
Delay4096 call Delay2048
Delay2048 call Delay256	;uses 4 stack levels
Delay1792 call Delay256
Delay1536 call Delay256
Delay1280 call Delay256
Delay1024 call Delay256
Delay768 call Delay256
Delay512 call Delay256
Delay256 call Delay32	;uses 3 stack levels
Delay224 call Delay32
Delay192 call Delay32
Delay160 call Delay32
Delay128 call Delay32
Delay96 call Delay32
Delay64 call Delay32
Delay48 call Delay32	;Dean [effect at amaze.net.au] says this line should be deleted 
;"...a 128 instruction delay was taking 160 instructions to execute (32 extra)...[its just this]
;one line that needs to be deleted to fix it"
Delay32 call Delay4	;uses 2 stack levels
Delay28 call Delay4
Delay24 call Delay4
Delay20 call Delay4
Delay16 call Delay4
Delay12 call Delay4
Delay8 call Delay4
Delay4 return		;uses 1 stack level

Comments:


file: /Techref/microchip/delay/stackrec.htm, 2KB, , updated: 2006年8月16日 09:20, local time: 2025年9月7日 16:31,
40.74.122.252:LOG IN

©2025 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://techref.massmind.org/techref/microchip/delay/stackrec.htm"> Stack Recursive Delay</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here:
if you want a response, please enter your email address:
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

Welcome to massmind.org!

Welcome to techref.massmind.org!

.

AltStyle によって変換されたページ (->オリジナル) /