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

📄 lcd.log

📁 FPGA 基于PICOBLAZE内核的LCD显示程序,完整,XILINX
💻 LOG
📖 第 1 页 / 共 3 页
字号:
 071  3006B            wait_1ms: CALL delay_40us[06B]
 072  1C201                      SUB s2, 01
 073  35471                      JUMP NZ, wait_1ms[071]
 074  2A000                      RETURN
 075                             ;
 075                             ;Delay of 20ms.
 075                             ;
 075                             ;Delay of 20ms used during initialisation.
 075                             ;
 075                             ;Registers used s0, s1, s2, s3
 075                             ;
 075  00314          delay_20ms: LOAD s3, 14                         ;20 x 1ms = 20ms
 076  30070           wait_20ms: CALL delay_1ms[070]
 077  1C301                      SUB s3, 01
 078  35476                      JUMP NZ, wait_20ms[076]
 079  2A000                      RETURN
 07A                             ;
 07A                             ;Delay of approximately 1 second.
 07A                             ;
 07A                             ;Registers used s0, s1, s2, s3, s4
 07A                             ;
 07A  00432            delay_1s: LOAD s4, 32                         ;50 x 20ms = 1000ms
 07B  30075             wait_1s: CALL delay_20ms[075]
 07C  1C401                      SUB s4, 01
 07D  3547B                      JUMP NZ, wait_1s[07B]
 07E  2A000                      RETURN
 07F                             ;
 07F                             ;
 07F                             ;
 07F                             ;**************************************************************************************
 07F                             ;LCD Character Module Routines
 07F                             ;**************************************************************************************
 07F                             ;
 07F                             ;LCD module is a 16 character by 2 line display but all displays are very similar
 07F                             ;The 4-wire data interface will be used (DB4 to DB7).
 07F                             ;
 07F                             ;The LCD modules are relatively slow and software delay loops are used to slow down
 07F                             ;KCPSM3 adequately for the LCD to communicate. The delay routines are provided in
 07F                             ;a different section (see above in this case).
 07F                             ;
 07F                             ;
 07F                             ;Pulse LCD enable signal 'E' high for greater than 230ns (1us is used).
 07F                             ;
 07F                             ;Register s4 should define the current state of the LCD output port.
 07F                             ;
 07F                             ;Registers used s0, s4
 07F                             ;
 07F  0E401         LCD_pulse_E: XOR s4, LCD_E[01]                   ;E=1
 080  2C440                      OUTPUT s4, LCD_output_port[40]
 081  30067                      CALL delay_1us[067]
 082  0E401                      XOR s4, LCD_E[01]                   ;E=0
 083  2C440                      OUTPUT s4, LCD_output_port[40]
 084  2A000                      RETURN
 085                             ;
 085                             ;Write 4-bit instruction to LCD display.
 085                             ;
 085                             ;The 4-bit instruction should be provided in the upper 4-bits of register s4.
 085                             ;Note that this routine does not release the master enable but as it is only
 085                             ;used during initialisation and as part of the 8-bit instruction write it
 085                             ;should be acceptable.
 085                             ;
 085                             ;Registers used s4
 085                             ;
 085  0A4F8     LCD_write_inst4: AND s4, F8                          ;Enable=1 RS=0 Instruction, RW=0 Write, E=0
 086  2C440                      OUTPUT s4, LCD_output_port[40]      ;set up RS and RW >40ns before enable pulse
 087  3007F                      CALL LCD_pulse_E[07F]
 088  2A000                      RETURN
 089                             ;
 089                             ;
 089                             ;Write 8-bit instruction to LCD display.
 089                             ;
 089                             ;The 8-bit instruction should be provided in register s5.
 089                             ;Instructions are written using the following sequence
 089                             ; Upper nibble
 089                             ; wait >1us
 089                             ; Lower nibble
 089                             ; wait >40us
 089                             ;
 089                             ;Registers used s0, s1, s4, s5
 089                             ;
 089  01450     LCD_write_inst8: LOAD s4, s5
 08A  0A4F0                      AND s4, F0                          ;Enable=0 RS=0 Instruction, RW=0 Write, E=0
 08B                             ;OR s4, LCD_drive                    ;Enable=1
 08B  30085                      CALL LCD_write_inst4[085]           ;write upper nibble
 08C  30067                      CALL delay_1us[067]                 ;wait >1us
 08D  01450                      LOAD s4, s5                         ;select lower nibble with
 08E  20407                      SL1 s4                              ;Enable=1
 08F  20406                      SL0 s4                              ;RS=0 Instruction
 090  20406                      SL0 s4                              ;RW=0 Write
 091  20406                      SL0 s4                              ;E=0
 092  30085                      CALL LCD_write_inst4[085]           ;write lower nibble
 093  3006B                      CALL delay_40us[06B]                ;wait >40us
 094  004F0                      LOAD s4, F0                         ;Enable=0 RS=0 Instruction, RW=0 Write, E=0
 095  2C440                      OUTPUT s4, LCD_output_port[40]      ;Release master enable
 096  2A000                      RETURN
 097                             ;
 097                             ;
 097                             ;
 097                             ;Write 8-bit data to LCD display.
 097                             ;
 097                             ;The 8-bit data should be provided in register s5.
 097                             ;Data bytes are written using the following sequence
 097                             ; Upper nibble
 097                             ; wait >1us
 097                             ; Lower nibble
 097                             ; wait >40us
 097                             ;
 097                             ;Registers used s0, s1, s4, s5
 097                             ;
 097  01450      LCD_write_data: LOAD s4, s5
 098  0A4F0                      AND s4, F0                          ;Enable=0 RS=0 Instruction, RW=0 Write, E=0
 099  0C40C                      OR s4, 0C                           ;Enable=1 RS=1 Data, RW=0 Write, E=0
 09A  2C440                      OUTPUT s4, LCD_output_port[40]      ;set up RS and RW >40ns before enable pulse
 09B  3007F                      CALL LCD_pulse_E[07F]               ;write upper nibble
 09C  30067                      CALL delay_1us[067]                 ;wait >1us
 09D  01450                      LOAD s4, s5                         ;select lower nibble with
 09E  20407                      SL1 s4                              ;Enable=1
 09F  20407                      SL1 s4                              ;RS=1 Data
 0A0  20406                      SL0 s4                              ;RW=0 Write
 0A1  20406                      SL0 s4                              ;E=0
 0A2  2C440                      OUTPUT s4, LCD_output_port[40]      ;set up RS and RW >40ns before enable pulse
 0A3  3007F                      CALL LCD_pulse_E[07F]               ;write lower nibble
 0A4  3006B                      CALL delay_40us[06B]                ;wait >40us
 0A5  004F0                      LOAD s4, F0                         ;Enable=0 RS=0 Instruction, RW=0 Write, E=0
 0A6  2C440                      OUTPUT s4, LCD_output_port[40]      ;Release master enable
 0A7  2A000                      RETURN
 0A8                             ;
 0A8                             ;
 0A8                             ;
 0A8                             ;Reset and initialise display to communicate using 4-bit data mode
 0A8                             ;Includes routine to clear the display.
 0A8                             ;
 0A8                             ;Requires the 4-bit instructions 3,3,3,2 to be sent with suitable delays
 0A8                             ;following by the 8-bit instructions to set up the display.
 0A8                             ;
 0A8                             ;  28 = '001' Function set, '0' 4-bit mode, '1' 2-line, '0' 5x7 dot matrix, 'xx'
 0A8                             ;  06 = '000001' Entry mode, '1' increment, '0' no display shift
 0A8                             ;  0E = '00001' Display control, '1' display on, '1' cursor off, '0' cursor blink off
 0A8                             ;  01 = '00000001' Display clear
 0A8                             ;
 0A8                             ;Registers used s0, s1, s2, s3, s4
 0A8                             ;
 0A8  30075           LCD_reset: CALL delay_20ms[075]                ;wait more that 15ms for display to be ready
 0A9  00430                      LOAD s4, 30
 0AA  30085                      CALL LCD_write_inst4[085]           ;send '3'
 0AB  30075                      CALL delay_20ms[075]                ;wait >4.1ms
 0AC  30085                      CALL LCD_write_inst4[085]           ;send '3'
 0AD  30070                      CALL delay_1ms[070]                 ;wait >100us
 0AE  30085                      CALL LCD_write_inst4[085]           ;send '3'
 0AF  3006B                      CALL delay_40us[06B]                ;wait >40us
 0B0  00420                      LOAD s4, 20
 0B1  30085                      CALL LCD_write_inst4[085]           ;send '2'
 0B2  3006B                      CALL delay_40us[06B]                ;wait >40us
 0B3  00528                      LOAD s5, 28                         ;Function set
 0B4  30089                      CALL LCD_write_inst8[089]
 0B5  00506                      LOAD s5, 06                         ;Entry mode
 0B6  30089                      CALL LCD_write_inst8[089]
 0B7  0050E                      LOAD s5, 0E                         ;Display control
 0B8  30089                      CALL LCD_write_inst8[089]
 0B9  00501           LCD_clear: LOAD s5, 01                         ;Display clear
 0BA  30089                      CALL LCD_write_inst8[089]
 0BB  30070                      CALL delay_1ms[070]                 ;wait >1.64ms for display to clear
 0BC  30070                      CALL delay_1ms[070]
 0BD  2A000                      RETURN
 0BE                             ;
 0BE                             ;Position the cursor ready for characters to be written.
 0BE                             ;The display is formed of 2 lines of 16 characters and each
 0BE                             ;position has a corresponding address as indicated below.
 0BE                             ;
 0BE                             ;                   Character position
 0BE                             ;           0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
 0BE                             ;
 0BE                             ; Line 1 - 80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F
 0BE                             ; Line 2 - C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
 0BE                             ;
 0BE                             ;This routine will set the cursor position using the value provided
 0BE                             ;in register s5. The upper nibble will define the line and the lower
 0BE                             ;nibble the character position on the line.
 0BE                             ; Example s5 = 2B will position the cursor on line 2 position 11
 0BE                             ;
 0BE                             ;Registers used s0, s1, s2, s3, s4
 0BE                             ;
 0BE  12510          LCD_cursor: TEST s5, 10                         ;test for line 1
 0BF  350C4                      JUMP Z, set_line2[0C4]
 0C0  0A50F                      AND s5, 0F                          ;make address in range 80 to 8F for line 1
 0C1  0C580                      OR s5, 80
 0C2  30089                      CALL LCD_write_inst8[089]           ;instruction write to set cursor
 0C3  2A000                      RETURN
 0C4  0A50F           set_line2: AND s5, 0F                          ;make address in range C0 to CF for line 2
 0C5  0C5C0                      OR s5, C0
 0C6  30089                      CALL LCD_write_inst8[089]           ;instruction write to set cursor
 0C7  2A000                      RETURN
 0C8                             ;
 0C8                             ;This routine will shift the complete display one position to the left.
 0C8                             ;The cursor position and LCD memory contents will not change.
 0C8                             ;
 0C8                             ;
 0C8                             ;Registers used s0, s1, s2, s3, s4, s5
 0C8                             ;
 0C8  00518      LCD_shift_left: LOAD s5, 18                         ;shift display left
 0C9  30089                      CALL LCD_write_inst8[089]
 0CA  2A000                      RETURN

⌨️ 快捷键说明

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