; Output: None.
; W, Index register & variable I will be broken.
;-------------------------------------------------------------------------
dsp_value
; *** Initialize ***
bsf LCD_RSEL, L_SELDR ; Select data register.
MOV lw LCD_STRBUF ; Set pointer of string.
MOV wf fsr ;
; *** Display sPACe (Zero suppless) ***
MOV lw MAXDIGIT-1 ; Set max space count.
MOV wf I ; (MAXDIGIT - 1)
dspvl_l1
MOV f I, w ; Exit this loop if
subwf LCD_DPOINT, w ; this loc. = decimal point or
btfsc status, z ; not zero.
goto dspvl_2s ;
;
MOV f indf, w ;
sublw ’0’ ;
btfss status, z ;
goto dspvl_2s ;
MOV lw ’ ’ ; Put ’ ’.
call set_LCD ;
incf fsr ; Set location to next.
decfsz I ;
goto dspvl_l1 ;
; *** Display number & decimal point ***
dspvl_2s
incf I ; Increment counter.
dspvl_l2
MOV f indf, w ; Display number.
call set_LCD ;
incf fsr ; Decrement counter &
decf I ; skip below if this loc
MOV f I, w ; is not decimal point loc.
subwf LCD_DPOINT, w ;
btfss status, z ;
goto dspvl_2e ;
MOV lw ’.’ ; Display decimal point.
call set_LCD ;
dspvl_2e
MOV f I, f ; Continue if I > 0.
btfss status, z ;
goto dspvl_l2 ;
; *** Return from subroutine ***
clrf LCD_RSEL ; Set to default.
return
;-------------------------------------------------------------------------
; Convert value of X to string. (Fixed 10 digits)
; Input : X[0]- X[3] (Value)
; EX[0]-EX[3]
; Output: LCD_STRBUF (Buffer of string for LCD)
; W, Index register & variable I, Y, EY will be broken.
;-------------------------------------------------------------------------
x_to_str
; *** Initialize ***
MOV lw LCD_STRBUF ; Set pointer of string.
addlw 9 ; (To bottom)
MOV wf fsr
上一页 [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单片机