Hardware Reference
In-Depth Information
lsra
; data pins
oraa
#lcd_E
; maintain the E signal value
staa
lcd_dat
; send the command, along with the RS and E signals
nop
; extend the duration of the E pulse
nop
;
nop
;
bclr
lcd_dat,lcd_E
; pull the E signal low
pula
; retrieve the LCD command
anda
#$0F
; clear the upper 4 bits
lsla
; match the lower 4 bits with the LCD
lsla
; data pins
bset
lcd_dat,lcd_E
; pull the E signal high
oraa
#lcd_E
; maintain the E signal value
staa
lcd_dat
; send the lower 4 bits of command with E and RS
nop
; extend the duration of the E pulse
nop
;
nop
;
bclr
lcd_dat,lcd_E
; clear the E signal to complete the write operation
ldy
#1
; adding this delay will complete the internal
jsr
delayby50us
; operation for most instructions
rts
Before using the LCD, the user must configure it properly. The configuration of the LCD
involves at least the following four LCD instructions:
1. Entry mode set. The common setting for this instruction is to move the cursor to the
right after reading or writing a character from or to the LCD.
2. Display on/off. The common setting for this instruction is to turn on the display,
cursor, and cursor blinking.
3. Function set. This instruction sets the number of rows for display, the font size, and
the width of the interface data (4 or 8 bits).
4. Clear display. Before outputting any data, it is always a good idea to clear the LCD
screen and move the cursor to the home position (upper left corner).
The following function performs the LCD confi guration:
openLCD
movb
#$FF,lcd_dir
; configure Port K for output
ldy
#10
; wait for LCD to be ready
jsr
delayby10ms
;
ldaa
#$28
; set 4-bit data, two-line display, 5 3 8 font
jsr
cmd2lcd
;
ldaa
#$0F
; turn on display, cursor, and blinking
jsr
cmd2lcd
; “
ldaa
#$06
; move cursor right (entry mode set instruction)
jsr
cmd2lcd
; “
ldaa
#$01
; clear display screen and return to home position
jsr
cmd2lcd
;
ldy
#2
; wait until clear display command is complete
jsr
delayby1ms
;
rts
 
Search WWH ::




Custom Search