;=======Subroutines========================================================
;~~~~~~~Delay Loop~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
delay movfw half_t ; copy half_t to accu
subwf _tmr0,w ; perform tmr0 - w, result in w
btfss _status,2 ; check if tmr0 = 0, return
goto delay ; tmr0 != 0, so loop.
retlw 0 ; else, return
;-------Untested
;delay clrf _tmr0 ; Start tmr0
;dloop movfw _tmr0 ; Read tmr0 into w, w holds time
; sublw half_t ; Time - half_t
; btfss _status,2 ; Check Time - half_t = 0
; goto dloop ; Time is not = half_t
; retlw 0 ; Time is half_t, return
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~