please dont rip this site

PIC Microcontoller Delay Method

by Myke Predko


Here is a good, generic Delay Macro that does not change "w" or the STATUS Flag. Note that it assumes that the "DlayCount" variable is equal to zero upon code entry.
DlayMacro Macro Cycles          ;  Delay Macro for Edges
 variable i, TCycles, Value, TFlag
TCycles = Cycles
Value = 1 << 7
i = 7
TFlag = 0
 if (TCycles > 5)
 while (i >= 0)
 if ((TFlag == 0) && ((Value * 3) <= TCycles))
  bsf    DlayCount, i
TFlag = 1
TCycles = TCycles - (Value * 3)
 if ((TFlag != 0) && (((Value * 3) + 1) <= TCycles))
  bsf    DlayCount, i
TCycles = TCycles - ((Value * 3) + 1)
Value = Value >> 1
i = i - 1
 if (TCycles > 3)
 Error "Delay Cycles too Large for Macro"
  decfsz  DlayCount, f
   goto   $ - 1
 while (TCycles > 1)
  goto   $ + 1
TCycles = TCycles - 2
 if (TCycles == 1)
  nop				;  Delay the Last Cycle

file: /Techref/microchip/delay/xb1cr-mp.htm, 1KB, , updated: 2007/6/22 15:07, local time: 2023/6/7 06:09,

 ©2023 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=""> PIC Microcontoller, Delay Method, Myke Predko</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!


Welcome to!