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

📄 lm032l.asm

📁 this program uses pic microcontroller for display temperature on a lcd monitor.
💻 ASM
📖 第 1 页 / 共 2 页
字号:
            RETURN
;
        else             ; 4-bit transfers on the low nibble of the PORT
;
;*******************************************************************
;* SEND_CHAR - Sends character to LCD                              *
;* This routine splits the character into the upper and lower      * 
;* nibbles and sends them to the LCD, upper nibble first.          *
;* The data is transmitted on the PORT<3:0> pins                   *
;*******************************************************************
;
SEND_CHAR
            MOVWF   CHAR            ; Character to be sent is in W
            CALL    BUSY_CHECK      ; Wait for LCD to be ready
            SWAPF   CHAR, W
            ANDLW   0x0F            ; Get upper nibble
            MOVWF   LCD_DATA        ; Send data to LCD
            BCF     LCD_CNTL, RW   ; Set LCD to read
            BSF     LCD_CNTL, RS    ; Set LCD to data mode
            BSF     LCD_CNTL, E     ; toggle E for LCD
            BCF     LCD_CNTL, E
            MOVF    CHAR, W
            ANDLW   0x0F            ; Get lower nibble
            MOVWF   LCD_DATA        ; Send data to LCD
            BSF     LCD_CNTL, E     ; toggle E for LCD
            BCF     LCD_CNTL, E
            RETURN
;
        endif
    else
;
;*****************************************************************
;* SEND_CHAR - Sends character contained in register W to LCD    *
;* This routine sends the entire character to the PORT           *
;* The data is transmitted on the PORT<7:0> pins                 *
;*****************************************************************
;
SEND_CHAR
            MOVWF   CHAR            ; Character to be sent is in W
            CALL    BUSY_CHECK      ; Wait for LCD to be ready
            MOVF    CHAR, w          
            MOVWF   LCD_DATA        ; Send data to LCD
            BCF     LCD_CNTL, RW   ; Set LCD in read mode
            BSF     LCD_CNTL, RS    ; Set LCD in data mode
            BSF     LCD_CNTL, E     ; toggle E for LCD
            BCF     LCD_CNTL, E
            RETURN
;
    endif
;
    page
;
;*******************************************************************
;* SendCmd - Sends command to LCD                                  *
;* This routine splits the command into the upper and lower        * 
;* nibbles and sends them to the LCD, upper nibble first.          *
;* The data is transmitted on the PORT<3:0> pins                   *
;*******************************************************************
;
    if ( Four_bit )      ; 4-bit Data transfers?
;
        if ( Data_HI )   ; 4-bit transfers on the high nibble of the PORT
;
;*******************************************************************
;* SEND_CMD - Sends command to LCD                                 *
;* This routine splits the command into the upper and lower        * 
;* nibbles and sends them to the LCD, upper nibble first.          *
;*******************************************************************

SEND_CMD
            MOVWF   CHAR            ; Character to be sent is in W
            CALL    BUSY_CHECK      ; Wait for LCD to be ready
            MOVF    CHAR,w          
            ANDLW   0xF0            ; Get upper nibble
            MOVWF   LCD_DATA        ; Send data to LCD
            BCF     LCD_CNTL,RW    ; Set LCD to read
            BCF     LCD_CNTL,RS     ; Set LCD to command mode
            BSF     LCD_CNTL,E      ; toggle E for LCD
            BCF     LCD_CNTL,E
            SWAPF   CHAR,w
            ANDLW   0xF0            ; Get lower nibble
            MOVWF   LCD_DATA        ; Send data to LCD
            BSF     LCD_CNTL,E      ; toggle E for LCD
            BCF     LCD_CNTL,E
            RETURN
;
        else             ; 4-bit transfers on the low nibble of the PORT
;
SEND_CMD
            MOVWF   CHAR            ; Character to be sent is in W
            CALL    BUSY_CHECK      ; Wait for LCD to be ready
            SWAPF   CHAR, W
            ANDLW   0x0F            ; Get upper nibble
            MOVWF   LCD_DATA        ; Send data to LCD
            BCF     LCD_CNTL, RW   ; Set LCD to read
            BCF     LCD_CNTL, RS    ; Set LCD to command mode
            BSF     LCD_CNTL, E     ; toggle E for LCD
            BCF     LCD_CNTL, E
            MOVF    CHAR, W
            ANDLW   0x0F            ; Get lower nibble
            MOVWF   LCD_DATA        ; Send data to LCD
            BSF     LCD_CNTL, E     ; toggle E for LCD
            BCF     LCD_CNTL, E
            RETURN
;
        endif
    else
;
;**************************************************************
;* SEND_CND - Sends command contained in register W to LCD    *
;* This routine sends the entire character to the PORT        *
;* The data is transmitted on the PORT<7:0> pins              *
;**************************************************************

SEND_CMD
            MOVWF   CHAR            ; Command to be sent is in W
            CALL    BUSY_CHECK      ; Wait for LCD to be ready
            MOVF    CHAR, w          
            MOVWF   LCD_DATA        ; Send data to LCD
            BCF     LCD_CNTL, RW   ; Set LCD in read mode
            BCF     LCD_CNTL, RS    ; Set LCD in command mode
            BSF     LCD_CNTL, E     ; toggle E for LCD
            BCF     LCD_CNTL, E
            RETURN
;
    endif
;
    page
;
    if ( Four_bit )      ; 4-bit Data transfers?
;
        if ( Data_HI )   ; 4-bit transfers on the high nibble of the PORT
;
;*******************************************************************
;* This routine checks the busy flag, returns when not busy        *
;*  Affects:                                                       *
;*      TEMP - Returned with busy/address                          *
;*******************************************************************
;
BUSY_CHECK
            BSF     STATUS, RP0     ; Select Register page 1
            MOVLW   0xFF            ; Set Port_D for input
            MOVWF   LCD_DATA_TRIS
            BCF     STATUS, RP0     ; Select Register page 0
            BCF     LCD_CNTL, RS    ; Set LCD for Command mode
            BSF     LCD_CNTL, RW   ; Setup to read busy flag
            BSF     LCD_CNTL, E     ; Set E high
            BCF     LCD_CNTL, E     ; Set E low
            MOVF    LCD_DATA, W     ; Read upper nibble busy flag, DDRam address
            ANDLW   0xF0            ; Mask out lower nibble
            MOVWF   TEMP
            BSF     LCD_CNTL, E     ; Toggle E to get lower nibble
            BCF     LCD_CNTL, E
            SWAPF   LCD_DATA, w     ; Read lower nibble busy flag, DDRam address
            ANDLW   0x0F            ; Mask out upper nibble
            IORWF   TEMP            ; Combine nibbles
            BTFSC   TEMP, 7         ; Check busy flag, high = busy
            GOTO    BUSY_CHECK      ; If busy, check again
            BCF     LCD_CNTL, RW        
            BSF     STATUS, RP0     ; Select Register page 1
            MOVLW   0x0F
            MOVWF   LCD_DATA_TRIS   ; Set Port_D for output
            BCF     STATUS, RP0     ; Select Register page 0
            RETURN
;
        else             ; 4-bit transfers on the low nibble of the PORT
;
;*******************************************************************
;* This routine checks the busy flag, returns when not busy        *
;*  Affects:                                                       *
;*      TEMP - Returned with busy/address                          *
;*******************************************************************
;
BUSY_CHECK
            BSF     STATUS, RP0     ; Bank 1
            MOVLW   0xFF            ; Set PortB for input
            MOVWF   LCD_DATA_TRIS
            BCF     STATUS, RP0     ; Bank 0
            BCF     LCD_CNTL, RS    ; Set LCD for Command mode
            BSF     LCD_CNTL, RW   ; Setup to read busy flag
            BSF     LCD_CNTL, E     ; Set E high
            BCF     LCD_CNTL, E     ; Set E low
            SWAPF   LCD_DATA, W     ; Read upper nibble busy flag, DDRam address
            ANDLW   0xF0            ; Mask out lower nibble
            MOVWF   TEMP            ;
            BSF     LCD_CNTL, E     ; Toggle E to get lower nibble
            BCF     LCD_CNTL, E
            MOVF    LCD_DATA, W     ; Read lower nibble busy flag, DDRam address
            ANDLW   0x0F            ; Mask out upper nibble
            IORWF   TEMP, F         ; Combine nibbles
            BTFSC   TEMP, 7         ; Check busy flag, high = busy
            GOTO    BUSY_CHECK      ; If busy, check again
            BCF     LCD_CNTL, RW
            BSF     STATUS, RP0     ; Bank 1
            MOVLW   0xF0            ;
            MOVWF   LCD_DATA_TRIS   ; RB7 - 4 = inputs, RB3 - 0 = output
            BCF     STATUS, RP0     ; Bank 0
            RETURN
;
        endif
    else
;
;**************************************************************
;* This routine checks the busy flag, returns when not busy   *
;*  Affects:                                                  *
;*      TEMP - Returned with busy/address                     *
;**************************************************************
;
BUSY_CHECK
            BSF     STATUS,RP0      ; Select Register page 1
            MOVLW   0xFF            ; Set port_D for input
            MOVWF   LCD_DATA_TRIS
            BCF     STATUS, RP0     ; Select Register page 0
            BCF     LCD_CNTL, RS    ; Set LCD for command mode
            BSF     LCD_CNTL, RW   ; Setup to read busy flag
            BSF     LCD_CNTL, E     ; Set E high
            BCF     LCD_CNTL, E     ; Set E low
            MOVF    LCD_DATA, w     ; Read busy flag, DDram address
            MOVWF   TEMP    
            BTFSC   TEMP, 7         ; Check busy flag, high=busy
            GOTO    BUSY_CHECK 
            BCF     LCD_CNTL, RW        
            BSF     STATUS, RP0     ; Select Register page 1
            MOVLW   0x00
            MOVWF   LCD_DATA_TRIS   ; Set port_D for output
            BCF     STATUS, RP0     ; Select Register page 0
            RETURN
;
    endif
    page
;
Table
            addwf   PCL, F          ;Jump to char pointed to in W reg
            retlw   'M'
            retlw   'i'
            retlw   'c'
            retlw   'r'
            retlw   'o'
            retlw   'c'
            retlw   'h'
            retlw   'i'
            retlw   'p'
            retlw   ' '
            retlw   'T'
            retlw   'e'
            retlw   'c'
            retlw   'h'
            retlw   'n'
            retlw   'o'
            retlw   'l'
            retlw   'o'
            retlw   'g'
            retlw   'y'
Table_End
            retlw   0
;
	if ( (Table & 0x0FF) >= (Table_End & 0x0FF) )
       MESSG   "Warning - User Definded: Table Table crosses page boundry in computed jump"
    endif
;



    end




⌨️ 快捷键说明

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