set_LCD
; *** Set command ***
MOV wf LCD_DATA
call set_LCDcmd
call wait_100us
; *** Return from subroutine ***
return
;-------------------------------------------------------------------------
; Set LCD command (Instruction).
; Input : LCD_RSEL (LCD register select)
; LCD_DATA (LCD data)
; Output: Port A, Port B (Data output port for LCD)
; W register will be broken.
;-------------------------------------------------------------------------
set_LCDcmd
; *** Select register ***
bcf portb, LCD_RS ; Select register.
btfsc LCD_RSEL, L_SELDR ;
bsf portb, LCD_RS ;
; *** Send upper nibbles ***
MOV lw 11110000b ; Set upper nibbles.
andwf porta, f ;
swapf LCD_DATA, w ;
andlw 00001111b ;
iorwf porta, f ;
bsf portb, LCD_LE ; Strobe.
nop ;
nop ;
bcf portb, LCD_LE ;
nop ;
nop ;
; *** Send lower nibbles ***
MOV lw 11110000b ; Set lower nibbles.
andwf porta, f ;
MOV f LCD_DATA, w ;
andlw 00001111b ;
iorwf porta, f ;
bsf portb, LCD_LE ; Strobe.
nop ;
nop ;
bcf portb, LCD_LE ;
; *** Return from subroutine ***
return
;-------------------------------------------------------------------------
; General: Add. (32 bits source + 32 bits destination)
; Input : X[0]-X[3] (Source : 32 bits)
; Y[0]-Y[3] (Destination: 32 bits)
; Output: X[0]-X[3] (Answer : 32 bits)
; W register will be broken.
;
; Allocations (MSB <-> LSB):
; X[3] X[2] X[1] X[0]
; Y[3] Y[2] Y[1] Y[0]
;-------------------------------------------------------------------------
add_xy
; *** Add Y to X ***
MOV f Y+0, w ; Lower.
addwf X+0, f ;
MOV lw 1 ;
btfsc status, c ;
addwf X+1, f ;
btfsc status, c ;
addwf X+2, f ;
btfsc status, c ;
addwf X+3, f ;
MOV f Y+1, w ; Middle lower.
addwf X+1, f ;
上一页 [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单片机