Bob Ammerman [RAMMERMAN at PRODIGY.NET] says:
I prefix my N*3 delay routine with a few instructions and branch to the right one for the desired delay.DELAY macro count local next local n n = (count) if n < D'1' error "Delay count less than 1" exitm endif if n < D'4' if (n & 1) nop endif if (n & 2) goto next next endif exitm endif if n <= D'7' call delay4-(n-4) exitm endif movlw (n-D'5')/D'3' call delay_3W_p4-((n+1) % 3) endm DELAY2 macro first,last DELAY last-first+1 endm ; Delay Routine delay_3W_p6: ;3N+6 from here down (includes call and return) movwf temp0 ;{1} delay_3W_p5: ;3N+5 from here down (includes call and return) movwf temp0 ;{1} delay_3W_p4: ;3N+4 from here down (includes call and return) movwf temp0 ;{1} delay_loop: ;3N+1 from here down (includes return) decfsz temp0,F ;{N+1} loop eats 3N-1 goto delay_loop ;{2N-2} return ;{2} delay7: nop delay6: nop delay5: nop delay4: return end
file: /Techref/microchip/delay/xb1cr-ba.htm, 1KB, , updated: 2007/6/22 14:05, local time: 2024/11/18 09:19,
3.147.126.146:LOG IN
|
©2024 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://sxlist.com/techref/microchip/delay/xb1cr-ba.htm"> PIC Microcontoller, Delay Method, Bob Ammerman</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. |
Welcome to sxlist.com! |
.