;Required Routines & Macros: ;--------------------------------------------------------------------------------------------- ;MACROS: ;--------------------------------------------------------------------------------------------- DELAY macro Time ;Delay "Cycles" instruction cycles if (Time==1) nop exitm endif if (Time==2) goto $ + 1 exitm endif if (Time==3) nop goto $ + 1 exitm endif if (Time==4) goto $ + 1 goto $ + 1 exitm endif if (Time==5) goto $ + 1 goto $ + 1 nop exitm endif if (Time==6) goto $ + 1 goto $ + 1 goto $ + 1 exitm endif if (Time==7) goto $ + 1 goto $ + 1 goto $ + 1 nop exitm endif if (Time%4==0) movlw (Time-4)/4 call Delay_Routine exitm endif if (Time%4==1) movlw (Time-5)/4 call Delay_Routine nop exitm endif if (Time%4==2) movlw (Time-6)/4 call Delay_Routine goto $ + 1 exitm endif if (Time%4==3) movlw (Time-7)/4 call Delay_Routine goto $ + 1 nop exitm endif endm ;--------------------------------------------------------------------------------------------- ; DELAY: ;--------------------------------------------------------------------------------------------- ;Delays 4w+4 cycles (including call,return, and movlw) (0=256) Delay_Routine addlw -1 ;Precise delays used in I/O btfss STATUS, Z goto Delay_Routine return |