⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcdkey2.asm

📁 这是一个4*4键盘控制液晶显示器的汇编语言程序。是用MICROCHIP的MPLAB IDE编写的。附有硬件连接方式。
💻 ASM
字号:
tmr0       equ 01h
z          equ 02h
status     equ 03h
rp0        equ 05h
tmr0b      equ 06h
portb      equ 06h
portc      equ 07h
portd      equ 08h
porte      equ 09h
value      equ 21h
temp       equ 22h
intcon     equ 0bh
option_reg equ 81h
trisb      equ 86h
trisc      equ 87h
trisd      equ 88h
trise      equ 89h
adcon1     equ 9fh

  org  000h;
main 
  nop
  bsf    status,rp0
  movlw  06h
  movwf  adcon1 
  movlw  07h
  movwf  option_reg  
  movlw  00h
  movwf  trisc
  movwf  trisd
  movwf  trise  
  movlw  0ffh
  movwf  trisb
  bcf    status,rp0
  clrf   portc
  clrf   porte  
  movlw  b'00000001'
  movwf  portd
  bsf    porte,1
  bcf    porte,1
  call   delay
;----------------------------
  movlw  b'00110000'
  movwf  portd
  bsf    porte,1
  bcf    porte,1
  call   delay
;---------------------------
  movlw  b'00001111'
  movwf  portd 
  bsf    porte,1
  bcf    porte,1
  call   delay
;--------------------------
  movlw  b'00000110'
  movwf  portd
  bsf    porte,1
  bcf    porte,1
  call   delay
;*******************************************
;*******************************************
check  
  call  scan
  movfw value
  addlw 0f0h
  andwf portd,0
  movwf value
  comf  value,1
  movfw value
  xorlw 80h
  btfsc status,z
  goto  check   
  call  delay
  call  delay
  call  scan
  movfw value
  addlw 0f0h
  andwf portd,0
  movwf value
  comf  value,1
  movfw value
  xorlw 80h
  btfsc status,z
  goto  check
  
  movfw value
  movwf portc
  movwf temp 
  call  trans    
  goto  check
;-------------------------
scan
  bsf status,rp0
  movlw 0fh
  movwf trisb
  bcf status,rp0    
scana  
  movlw b'11101111'
  movwf portd
  movlw 00h
  movwf portb
  nop
  nop    
  movf  portb,0    
  andlw 0fh    
  movwf value
  xorlw 0fh
  btfsc status,z
  goto  scanb
  return
scanb
  movlw b'11011111'
  movwf portd
  movlw 00h
  movwf portb
  nop
  nop    
  movf  portb,0    
  andlw 0fh    
  movwf value
  xorlw 0fh
  btfsc status,z
  goto  scanc
  return
scanc
  movlw b'10111111'
  movwf portd
  movlw 00h
  movwf portb
  nop
  nop    
  movf  portb,0    
  andlw 0fh    
  movwf value
  xorlw 0fh
  btfsc status,z
  goto  scand
  return
scand
  movlw b'01111111'
  movwf portd
  movlw 00h
  movwf portb
  nop
  nop    
  movf portb,0    
  andlw 0fh    
  movwf value
  xorlw 0fh
  btfsc status,2
  goto  nokey
  return
;****************************** 
;******************************
delay
  bcf intcon,2
  movlw tmr0b
  movwf tmr0
loop1
  btfss intcon,2
  goto loop1
  return    
;------------------------------
nokey
    movlw 0fh
    movwf value
    return 
;------------------------------
trans
  movlw  b'10001000'
  subwf  temp,0
  btfsc  status,z;  
  goto   show1
    
  movlw  b'10000100'
  subwf  temp,0
  btfsc  status,z
  goto   show2
  
  movlw  b'10000010'
  subwf  temp,0
  btfsc  status,z
  goto  show3
  
  movlw  b'10000001'
  subwf  temp,0
  btfsc  status,z
  goto   show4
 
  movlw  b'01001000'
  subwf  temp,0
  btfsc  status,z
  goto   show5
  
  movlw  b'01000100'
  subwf  temp,0
  btfsc  status,z
  goto   show6
 
  movlw  b'01000010'
  subwf  temp,0
  btfsc  status,z
  goto   show7
  
  movlw  b'01000001'
  subwf  temp,0
  btfsc  status,z
  goto   show8
 
  movlw  b'00101000'
  subwf  temp,0
  btfsc  status,z
  goto   show9
  
  movlw  b'00100100'
  subwf  temp,0
  btfsc  status,z
  goto   show0
 
  movlw  b'00100010'
  subwf  temp,0
  btfsc  status,z
  goto   showA
  
  movlw  b'00100001'
  subwf  temp,0
  btfsc  status,z
  goto   showB
  
  movlw  b'00011000'
  subwf  temp,0
  btfsc  status,z
  goto   showC
  
  movlw  b'00010100'
  subwf  temp,0
  btfsc  status,z
  goto   showD
  
  movlw  b'00010010'
  subwf  temp,0
  btfsc  status,z
  goto   showE
  
  movlw  b'00010001'
  subwf  temp,0
  btfsc  status,z
  goto   showF
;--------------------------
show1
  movlw  b'00110001'
  movwf  portd    
  goto   showlcd
show2
  movlw  b'00110010'
  movwf  portd    
  goto   showlcd
show3
  movlw  b'00110011'
  movwf  portd    
  goto   showlcd
show4
  movlw  b'00110100'
  movwf  portd    
  goto   showlcd
show5
  movlw  b'00110101'
  movwf  portd    
  goto   showlcd
show6
  movlw  b'00110110'
  movwf  portd    
  goto   showlcd
show7
  movlw  b'00110111'
  movwf  portd
  goto   showlcd
show8
  movlw  b'00111000'
  movwf  portd
  goto   showlcd
show9
  movlw  b'00111001'
  movwf  portd
  goto   showlcd
show0
  movlw  b'00110000'
  movwf  portd
  goto   showlcd
showA
  movlw  b'01000001'
  movwf  portd
  goto   showlcd
showB
  movlw  b'01000010'
  movwf  portd
  goto   showlcd
showC
  movlw  b'01000011'
  movwf  portd
  goto   showlcd
showD
  movlw  b'01000100'
  movwf  portd
  goto   showlcd
showE
  movlw  b'01000101'
  movwf  portd
  goto   showlcd
showF
  movlw  b'01000110'
  movwf  portd
  goto   showlcd
;--------------------
showlcd
  movlw  02h
  movwf  porte
  movlw  03h
  movwf  porte
  movlw  01h
  movwf  porte
  return 
;-------------------
  end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -