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) else if ((TFlag != 0) && (((Value * 3) + 1) <= TCycles)) bsf DlayCount, i TCycles = TCycles - ((Value * 3) + 1) endif endif Value = Value >> 1 i = i - 1 endw if (TCycles > 3) Error "Delay Cycles too Large for Macro" endif decfsz DlayCount, f goto $ - 1 endif while (TCycles > 1) goto $ + 1 TCycles = TCycles - 2 endw if (TCycles == 1) nop ; Delay the Last Cycle endif endm
|file: /Techref/microchip/delay/xb1cr-mp.htm, 1KB, , updated: 2007/6/22 14:07, local time: 2022/12/7 07:58,
|©2022 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?|
<A HREF="http://piclist.com/techref/microchip/delay/xb1cr-mp.htm"> PIC Microcontoller, Delay Method, Myke Predko</A>
|Did you find what you needed?|
PICList 2022 contributors:
o List host: MIT, Site host massmind.org, Top posters @none found
- Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated!
* Contributors: Richard Seriani, Sr.
Welcome to piclist.com!