Keeping these steps in mind we can write LCD command routine as.
CODE:
LCD_data,A
LCD_rs
LCD_rw
LCD_en
LCD_en
LCD_busy
The equivalent C code Keil C compiler. Similar code can be written for SDCC.
CODE:
The seventh bit is always 1, and bit 0 to 7 are DDRAM address (See
theintroduction section of LCD). so if you want to put the cursor on first
position the address will be '0000000B' in binary and 7th bit is 1. so address
will be 0x80, so for DDRAM all address starts from 0x80.
For 2 line and 16 character LCD. The adress from 0x80 to 0x8F are visible on
first line and 0xC0 to 0xCF is visible on second line, rest of the DDRAM area is
still available but is not visible on the LCD, if you want to check this thing,
then simply put a long sting greater than 16 character and shift the entire
display, you will see all the missing character coming from the back.. this way
you can make scrolling line on LCD (see more on shifting display in commands
section).
Below is an example for setting cursor position on LCD.
CODE:
CODE:
// to do the same thing is C
// as we done before
LCD_command(0x83);
Keeping these steps in mind we can write LCD command routine as.
CODE:
LCD_data,A
LCD_rs
LCD_rw
LCD_en
LCD_en
LCD_busy
The equivalent C code Keil C compiler. Similar code can be written for SDCC.
CODE:
Now you have seen that its really easy to send command and data to LCD.
Now what if we have a string to send to LCD? how we are going to do that?
Is simple, we will store the LCD string in the ROM of controller and call the
string character by character. A simple exmple is shown below.
CODE:
To store a string..
my_string:
DB
"LCD Tutorial", 00H
00H indicate that string is finished.
The equivalent C code Keil C compiler. Similar code can be written for SDCC.
CODE: