Specifications
mikroElektronika | Free Online Book | PIC Microcontrollers | Appendix B: Examples
movlw LCDcommand
call LCDcomd
ENDM
LCDcomd
movwf LCDbuf
bcf LCDportBuf, RS
movf LCDportBuf, w
movwf LCDport
goto LCDwr
LCDdata
movwf LCDbuf
bsf LCDportBuf, RS
movf LCDportBuf, w
movwf LCDport
goto LCDwr
LCDwr
swapf LCDbuf, w
call SendW
movf LCDbuf, w
call SendW
return
SendW
andlw 0x0F
movwf LCDtemp
movlw 0xF0
andwf LCDportBuf, f
movf LCDtemp, w
iorwf LCDportBuf, f
movf LCDportBuf, w
movwf LCDport
call Delay1ms
bsf LCDportBuf, EN
movf LCDportBuf, w
movwf LCDport
bcf LCDportBuf, EN
movf LCDportBuf, w
movwf LCDport
call Delay1ms
return
;**********************************************************************
; lcdtext writes text containing 16 characters which represents a
; macro argument. The first argument select selects the line in which
; text writing is to start. If select is 0, text writing starts from
; cursor current position.
;**********************************************************************
lcdtext MACRO select, text ; This macro writes text from cursor
; current position. Text is specified
; in argument consisting of 16 charac
; ters
local Message
local Start
local Exit
local i=0
goto Start
Message DT text ; Create lookup table from arguments
DT 0
Start
IF (select == 1)
lcdcmd b'10000000'
ELSE
IF (select == 2)
lcdcmd b'11000000'
ENDIF
ENDIF
WHILE (i<16) ; Repeat conditional program compiling 16 times
call Message+i ; Read lookup table and place value in W
addlw 0
bz Exit ; until 0 is read
call LCDdata ; Call routine displaying W on LCD
http://www.mikroe.com/en/books/picmcubook/appb/ (50 of 54)5/3/2009 11:36:02 AM