Mike - K8LH
Well-Known Member
I'm trying to design a simple set of Dallas/Maxim One-Wire assembly procedures/functions and I'd like to support a 'standard' set of Clocks for the delay routines.
What 'standard' set of frequencies should I support? 4, 8, 10, 16, 20, 32, 40?
On a similar note, does anyone have 'generic' delay code they'd like to share? I've come up with a simple method (below) that doesn't require a GPR variable but it's only good for delay value constants known at compile time.
Mike
What 'standard' set of frequencies should I support? 4, 8, 10, 16, 20, 32, 40?
On a similar note, does anyone have 'generic' delay code they'd like to share? I've come up with a simple method (below) that doesn't require a GPR variable but it's only good for delay value constants known at compile time.
Mike
Code:
;******************************************************************
;
; DelayUS Macro (for constant values known at compile time)
;
; passed parameter: 10 to 1289 (usecs in 1 usec steps)
;
DelayUS macro pTime ;
movlw (pTime/5)-1 ; |B0
call Delay5us-(pTime%5)
endm
;
;******************************************************************
if Clock == 8
;******************************************************************
;
; Delay code for 8-MHz clock (14 bit core)
;
goto $+1 ; 1 usec |B0
goto $+1 ; 1 usec |B0
goto $+1 ; 1 usec |B0
goto $+1 ; 1 usec |B0
Delay5us
call Wx ; 2 usec |B0
goto $+1 ; 1 usec |B0
addlw -1 ;.5 usec |B0
skpz ;.5 usec |B0
goto Delay5us ; 1 usec |B0
call Wx ; 2 usec |B0
nop ;.5 usec |B0
Wx return ; 2 usec |B0
;******************************************************************
endif
if Clock == 4
;******************************************************************
;
; Delay code for 4-MHz clock (14 bit core)
;
nop ; 1 usec |B0
nop ; 1 usec |B0
nop ; 1 usec |B0
nop ; 1 usec |B0
Delay5us
nop ; 1 usec |B0
addlw -1 ; 1 usec |B0
skpz ; 1 |B0
goto Delay5us ; 2 usec |B0
nop ; 1 usec |B0
return ; 2 usec |B0
;******************************************************************
endif