;
decfsz I ;
goto sgt_loop ;
end_sgt
MOV f X+0, w ; GATETIME <- X.
MOV wf GATETIME+0 ;
MOV f X+1, w ;
MOV wf GATETIME+1 ;
; *** Set Internal prescaler rate ***
MOV f INT_PSC, w ; Get TMR0 rate.
call get_iprtm0 ;
bsf status, rp0 ; Select bank 1.
MOV wf option ; set new TMR0 rate.
bcf status, rp0 ; Select bank 0. (Default)
; *** Return from subroutine ***
return
;-------------------------------------------------------------------------
; Count procedure.
; Input : GATETIME (Gate time in milliseconds)
; Output: CNT (Value)
; W register & variable I, X, Y will be broken.
;-------------------------------------------------------------------------
count
; *** Prologue ***
MOV f GATETIME+0, w ; I <- GATETIME * 100.
MOV wf X+0 ; (Convert milliseconds to
MOV f GATETIME+1, w ; 10 microseconds)
MOV wf X+1 ;
clrf X+2 ; I: Count loop counter.
clrf X+3 ; (Use lower 24 bits)
;
MOV lw 64h ;
MOV wf Y+0 ;
clrf Y+1 ;
clrf Y+2 ;
clrf Y+3 ;
;
call mul_xy ;
;
MOV f X+0, w ;
MOV wf I+0 ;
MOV f X+1, w ;
MOV wf I+1 ;
MOV f X+2, w ;
MOV wf I+2 ;
clrf CNT+0 ; Clear pulse counter.
clrf CNT+1 ;
clrf CNT+2 ;
; Clear RTCC & init OLD value of RTCC.
clrw ;(But you may not clear it)
MOV wf tmr0 ; RTCC is disabled to increment
MOV wf RTC_OLD ; for 2 instruction cycles after
nop ; it is modified.
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22] [23] [24] [25] 下一页
本文关键字:单片机 PIC单片机,单片机-工控设备 - PIC单片机