您当前的位置:五五电子网电子知识单片机-工控设备源码-程序PIC16Fxxx的LCD驱动程序(适用于HD44780兼容 正文
PIC16Fxxx的LCD驱动程序(适用于HD44780兼容

PIC16Fxxx的LCD驱动程序(适用于HD44780兼容

点击数:7163 次   录入时间:03-04 11:42:34   整理:http://www.55dianzi.com   源码-程序
  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

www.55dianzi.com
  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

;*******************************************************************
;* 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] 


本文关键字:程序  源码-程序单片机-工控设备 - 源码-程序