• <li id="00i08"><input id="00i08"></input></li>
  • <sup id="00i08"><tbody id="00i08"></tbody></sup>
    <abbr id="00i08"></abbr>
  • 新聞中心

    EEPW首頁 > 嵌入式系統 > 設計應用 > PIC16Fxxx的LCD驅動程序(適用于HD44780兼容

    PIC16Fxxx的LCD驅動程序(適用于HD44780兼容

    作者: 時間:2011-05-17 來源:網絡 收藏

    ;
    ;*********************************************************************
    ;* To put the HEX value to Display ,,
    ;* High nibble first than Low nibble
    ;* Input : W Reg.
    ;*********************************************************************
    PutHex
    banksel W_BUFR
    movwf W_BUFR ; Save W Register !!
    swapf W_BUFR,W ; High nibble first !!
    call Hex2ASCII
    call putc
    ;
    movf W_BUFR,W
    call Hex2ASCII
    call putcLCD
    return
    ;
    ;******************************************************************
    ;* Convert a low nibble to ASCII code
    ;* Input : W Reg.
    ;* Output: W Reg.
    ;******************************************************************
    Hex2ASCII
    andlw 0x0f ; Mask Bit 4 to 7
    movwf Hex_Bfr
    sublw .09
    btfsc STATUS,C ; If W less than A (C=1) --> only add 30h
    goto Add_W_30
    Add_W_37 movlw 0x37
    goto Hex_cont
    Add_W_30 movlw 0x30
    Hex_cont addwf Hex_Bfr,W ; The correct ASCII code for this char !!
    return
    ;
    ;*******************************************************************
    ;* 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. *
    ;*******************************************************************
    SendCmd
    banksel Byte
    movwf Byte ; Save WREG in Byte variable
    call Delay_1MS
    swapf Byte,W ; Send upper nibble first
    andlw 0x0f
    movwf LCD_DATA
    bcf LCD_CNTL,RS ; Clear for command
    bsf LCD_CNTL,E ; Clock nibble into LCD
    bcf LCD_CNTL,E
    movf Byte,W ; Write lower nibble last
    Send_4bit andlw 0x0f
    movwf LCD_DATA
    bcf LCD_CNTL,RS ; Clear for command
    bsf LCD_CNTL,E ; Clock nibble into LCD
    bcf LCD_CNTL,E
    return
    ;
    ;*******************************************************************
    ;* clrLCD - Clear the contents of the LCD *
    ;*******************************************************************
    clrLCD
    movlw CLR_DISP ; Send the command to clear display
    call SendCmd
    return
    ;
    ;*******************************************************************
    ;* L1homeLCD - Moves the cursor to home position on Line 1 *
    ;*******************************************************************
    L1homeLCD
    movlw DD_RAM_ADDR|0x00 ; Send command to move cursor to
    call SendCmd ; home position on line 1
    return

    本文引用地址:http://www.czjhyjcfj.com/article/150736.htm

    ;*******************************************************************
    ;* L2homeLCD - Moves the cursor to home position on Line 2 *
    ;*******************************************************************
    L2homeLCD
    movlw DD_RAM_ADDR|0x28 ; Send command to move cursor to
    call SendCmd ; home position on line 2
    return


    ;*******************************************************************
    ;* Delay - Generic LCD delay (1.024mS @ 4MHz) *
    ;* Since the microcontroller can not read the busy flag of the *
    ;* LCD, a specific delay needs to be executed between writes to *
    ;* the LCD. *
    ;*******************************************************************
    Delay_1MS ; 2 cycles for call
    clrf Count ; 1 cycle to clear counter variable
    Dloop
    nop
    decfsz Count,F ; These two instructions provide a
    goto Dloop ; (256 * 3) -1 cycle count
    return ; 2 cycles for return
    ;
    ;*******************************************************************
    ;* Delay - 1mS base delay *
    ;* input : W Reg. *
    ;* *
    ;*******************************************************************
    Delay_MS
    movwf Count1
    ;
    DLop1 call Delay_1MS
    decfsz Count1,F
    goto DLop1
    return
    ;
    END


    上一頁 1 2 下一頁

    評論


    相關推薦

    技術專區

    關閉
    主站蜘蛛池模板: 阳西县| 江孜县| 云安县| 鞍山市| 北京市| 岳池县| 丹阳市| 汉川市| 肇州县| 安丘市| 赞皇县| 桃源县| 冕宁县| 稻城县| 凤台县| 建瓯市| 广河县| 富裕县| 巩留县| 小金县| 万州区| 兴和县| 汶上县| 开远市| 梁平县| 临汾市| 海原县| 剑河县| 宜宾市| 黑山县| 苗栗市| 黎川县| 洪泽县| 通河县| 莱芜市| 时尚| 和政县| 阜平县| 镇坪县| 蓝田县| 三台县|