Hardware Reference
In-Depth Information
Step 3
Pull the E signal to high.
Step 4
Output data to the output port attached to the LCD data bus. We need to configure the I/O
port for output before writing data to the LCD kit.
Step 5
Pull the E signal to low and make sure that the internal operation is complete.
The procedure for writing a byte to the LCD data register is as follows:
Step 1
Pull the RS signal to high.
Step 2
Pull the R/W signal to low.
Step 3
Pull the E signal to high.
Step 4
Output data to the I/O port attached to the LCD data bus.
Step 5
Pull the E signal to low and make sure that the internal operation is complete.
These procedures need to be repeated once for an LCD kit that has a 4-bit interface.
The following constant definitions will be used in the specified functions:
lcd_dat equ PTK ; LCD data pins (PK5 , PK2)
lcd_dir equ DDRK ; LCD data direction port
lcd_E equ $02 ; E signal pin
lcd_RS equ $01 ; RS signal pin
All of the LCD commands take a much longer time to complete than an instruction
does. There is always a possibility that the LCD is still busy with its internal operation
when we want to send a new command to the LCD. There are two methods for solving this
problem.
1. The cmd2LCD function calls a subroutine to make sure that the LCD is idle before
proceeding with the new command. After performing the desired operation, the
cmd2lcd function simply returns without waiting for the internal LCD operation to
complete. This approach cannot work with the Dragon12 demo board.
2. The cmd2LCD function performs the desired operation, waits for 40
μ
s (or slightly
s, all except two instructions
(clear display and cursor home) will be completed. For these two instructions, the
caller needs to call a delay subroutine to wait until the internal LCD operation is
completed before proceeding with other operations.
The function that sends a command to the LCD kit using the second approach is as
follows:
cmd2LCD
longer), and then returns to the caller. By waiting for 40
μ
psha
; save the command in stack
bclr
lcd_dat,lcd_RS
; select the instruction register
bset
lcd_dat,lcd_E
; pull the E signal high
anda
#$F0
; clear the lower 4 bits
lsra
; match the upper 4 bits with the LCD
 
Search WWH ::




Custom Search