For long delays (> 10 cycles) the code is based on nested loops using 'decfsz' and 'goto' instructions. Small delays are built using 'goto $ + 1' (2 cycles delay) and 'nop' (one cycle delay).
To calculate nested loop counter values the code generator uses an optimum search algorithm. The algorithm finds such values for counters that achieve good approximation to the specified delay.
Even if there is an error in the first block of nested loops, the rest of the code fixes that. As a result, one cycle resolution is achieved.
Idea: James Newton
Implementation: Nikolai
Golovchenko
See:
See also:
Questions:
Daniel Chia Jin Hao Says:
For PIC18, this delay routine will need a little modification to work properly.. the goto $+1 within the delay loops that sometimes appears needs to be changed to goto $+6, since each program word is 2 bytes, and goto is a 4 byte instruction. Also, at the end sometimes goto $+1 is used as a 2 cycle delay, need to use goto $+4 to skip over the whole goto.+
I hope this is correct, AFAIK it is.
Comments:
| file: /techref/piclist/codegen/delay.htm, 4KB, , updated: 2008/4/3 09:28, local time: 2008/11/20 09:23,
38.103.63.55:LOG IN
|
| ©2008 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! <A HREF="http://www.sxlist.com/techref/piclist/codegen/delay.htm"> Delay Code Generator </A> |
| Did you find what you needed? |
Welcome to sxlist.com!sales, advertizing, & kind contributors just like you! Please don't rip/copy (here's why Copies of the site on CD are available at minimal cost. |
|
.