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

📄 test8.asm

📁 基于单片机C51和LCD1602的显示《将近酒》的程序
💻 ASM
📖 第 1 页 / 共 5 页
字号:
          mov a,#0b4h
          call tcom
          call mlfs
          call disp
mov dptr,#sun22
          mov a,#0b5h
          call tcom
          call mlfs
          call disp3
mov dptr,#sun23
          mov a,#0b6h
          call tcom
          call mlfs
          call disp
mov dptr,#sun23
          mov a,#0b7h
          call tcom
          call mlfs
          call disp3
          ret
show_pic7:mov dptr,#sun24
          mov a,#0b0h
          call tcom
          call mlfs
          call disp
mov dptr,#sun24
          mov a,#0b1h
          call tcom
          call mlfs
          call disp3
mov dptr,#sun25
          mov a,#0b2h
          call tcom
          call mlfs
          call disp
mov dptr,#sun25
          mov a,#0b3h
          call tcom
          call mlfs
          call disp3
mov dptr,#sun26
          mov a,#0b4h
          call tcom
          call mlfs
          call disp
mov dptr,#sun26
          mov a,#0b5h
          call tcom
          call mlfs
          call disp3
mov dptr,#sun27
          mov a,#0b6h
          call tcom
          call mlfs
          call disp
mov dptr,#sun27
          mov a,#0b7h
          call tcom
          call mlfs
          call disp3
          ret

show_pic8:mov dptr,#sun28
          mov a,#0b0h
          call tcom
          call mlfs
          call disp
mov dptr,#sun28
          mov a,#0b1h
          call tcom
          call mlfs
          call disp3
mov dptr,#sun29
          mov a,#0b2h
          call tcom
          call mlfs
          call disp
mov dptr,#sun29
          mov a,#0b3h
          call tcom
          call mlfs
          call disp3
mov dptr,#sun30
          mov a,#0b4h
          call tcom
          call mlfs
          call disp
mov dptr,#sun30
          mov a,#0b5h
          call tcom
          call mlfs
          call disp3
mov dptr,#sun31
          mov a,#0b6h
          call tcom
          call mlfs
          call disp
mov dptr,#sun31
          mov a,#0b7h
          call tcom
          call mlfs
          call disp3
          ret







;子程序:
;===LCM initalization 初始化=======
LCM_INIT:
 LCALL    DELAY
 CLR      RES             ;initalization  reset   硬复位
 LCALL    DELAY
 LCALL    DELAY
 SETB RES
 LCALL    DELAY
 MOV      A,#11100010B  ;initialize interal function软件复位
 LCALL    TCOM
 LCALL    DELAY
 MOV      A,#10100010B         ;set LCD bias=1/9 LCD偏压设置LCD bias=1/9
 LCALL    TCOM
 MOV      A,#11001000B   ;set SHL COM1 to COM64 =C0H,set SHL COM64 to COM1 =C8H    确定COM口扫描的方向,现在为COM63-COM0
 LCALL    TCOM
 MOV      A,#10100000B         ;ADC select SEG0 to SEG131  A1H 显示图像左右镜像  ADC选择
 LCALL    TCOM
 MOV      A,#01000000B         ;Initial Display Line   设置了对应显示屏上首行的显示RAM行号
 LCALL    TCOM
 MOV      A,#00101100B      ;上电控制设置
 LCALL    TCOM
 LCALL    DELAY
 MOV      A,#00101110B      ;上电控制设置
 LCALL    TCOM
 LCALL    DELAY
 MOV      A,#00101111B         ;power control(VC,VR,VF=1,1,1)  上电控制设置
 LCALL    TCOM
 LCALL    DELAY
     ;----------------------------
 MOV      A,#00100011B        ;Regulator resistor select    对比度设置 020H~027H  V5电压内部电阻调整设置
 LCALL    TCOM
 MOV      A,#10000001B         ;set reference voltage mode 设置为电量设置模式
 LCALL    TCOM
 MOV      A,#00011001B         ;set reference voltage  亮度电压调节 00H~03FH  先发指令 81H,后写具体值
 LCALL    TCOM
     ;以上2条指令互相配合可以调节到合适得对比度

 MOV      A,#10100110B         ;set reverse display OFF,正反显示设置;A6正显示;A7反显示 ;现为正显示
 LCALL    TCOM
 MOV      A,#11010010B         ;driving mode set  驱动模式设置
 LCALL    TCOM
 MOV      A,#000H         ;MODE 1  选择模式2
 LCALL    TCOM
 MOV      A,#10101111B         ;turns the display ON  开启显示
 LCALL    TCOM
 ret
;===延时子程序=================================

DELAY:       ;time = 40Hx(41Hx2+1+2)us   CY=12MHZ
  MOV 40H,#0100 ;10.05ms   ;32h
DELAY1:
  MOV 41H,#051
DELAY2:
   DJNZ 41H,DELAY2 ;192us
   DJNZ 40H,DELAY1
   RET


delay_2s:mov r4,#10h
pol:mov r7,#0ffh
loop:mov r6,#0ffh
     mov r5,#0ffh
loop1:djnz r5,loop1
loop2:djnz r6,loop2
      djnz r7,loop
      djnz r4,pol
      ret
;=====送命令,CS1=0 A0=0  RD=1,RW 0-->1
TCOM:
 SETB RES
 SETB CS1
 setb RW
 setb E_RD
 CLR A0                         ;A0=0
 nop
 nop
 CLR CS1                        ;CS1=0
 nop
 nop
 mov data_bus,a                 ;DATA
 nop
 nop
 clr rw                         ;RW 0-->1
 nop
 nop
 setb rw
 setb cs1
 SETB A0
 setb E_RD
 SETB RES
 ret


;=======送显示数据=======   A0=1  CS1=0  RD=1 RW 0-->1
TDATA:
  SETB RES
  SETB CS1
  SETB A0
  SETB RW
  CLR CS1
  SETB E_RD

TRANSMIT:
 MOV DATA_bus,A
 SETB RW
 NOP
 NOP
 NOP
 CLR RW
 nop
 nop
 SETB CS1
 SETB E_RD
 SETB RW
 SETB A0
 SETB RES
 RET

;==========清屏==========================================
;实际上就是RAM中全写00H
;========================================================
clr_screen:
  mov r2,#0B0h
 clr_2:
  MOV A,R2 ;set page address
  LCALL TCOM
  MOV A,#010H ;set column address MSB  ;列地址
  LCALL TCOM
  MOV A,#00H ;set column address LSB   ;列地址
  LCALL TCOM
  MOV R1,#010H ;set (8*8)*16characters
 clr1:
   MOV R0,#08H
 clr0:
   mov a,#00h
   call tdata
   DJNZ R0,clr0
   DJNZ R1,clr1
   INC R2
   LCALL DELAY
   CJNE R2,#0B8H,clr_2
  ret
;----------------CLR Screen Over-------------------------
;====忙查寻==============================================
;在高速中,使用忙查询会稳定显示效果
;========================================================
busy_check:
 mov data_bus,#0FFH
 mov a,data_bus
 SETB CS1
 CLR CS1                     ;cs1=0
 CLR A0                      ;a0=0
 setb RW                     ;RW=1
 clr e_rd                    ;RD=0
 nop
 nop
 mov a,data_bus
 setb e_rd

 nop
 nop
 setb cs1                   ;

 ;jmp busy_check

 ret
;=========把取字模的数据显示在液晶上======================
;在使用前请指定数据地址,用mov dptr,
;使用寄存器r0
;=========================================================
disp:
     inc dptr
     mov r0,#1
disp1:mov a,#0
     movc a,@a+dptr
     call tdata
     inc dptr
     inc dptr
     inc r0

⌨️ 快捷键说明

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