Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Help with LCD interface microcontroller

Status
Not open for further replies.

scs83

Junior Member level 1
Joined
Oct 7, 2004
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
182
lcd interfacing microcontroller

Hi,

I really need some help here. I am currently doing a scientific calculator project and I am having some trouble interfacing it with the microcontroller. I have a source code reference in this website https://instruct1.cit.cornell.edu/courses/ee476/FinalProjects/s1999/sam/LCD.ASM

It uses two 16X1 LCD but I wish to use only one 16X2 LCD. Can anyone help me with this? I am very poor with programming as I am new.

Thank you.
 

hd44780 carriage return

I do not know what microcontroller you are using, but from the comments it seems the display controller you are using is Hitachi's HD44780.
If that is correct, then to use the second line you just need to set the address of the next character to be displayed to 40H, which is the beginning of the second line.

Another thing to remember is that this HD44780 is used with other types of displays, such as 20x2 or 24x2. But the first line always starts at DD RAM address 00H and the second one at 40H.

The chip has more memory locations (40x2) than most LCD's have characters, so you only see the first 16, 20 or 24, etc characters from the beginning of each line. The rest of the locations can be used as general-purpose RAM.

Note also that the end of the first line and the beginning of the second are not consecutive.

I hope this helps. Else, please post the exact chip type you are using.
 

    scs83

    Points: 2
    Helpful Answer Positive Rating
types of lcd interfaces

Hi vvv,

I am using Atmel 8515 microcontroller and Hitachi HD44780 LCD. I am currently doing a project based on that website in my first post. I planned to use a 16X2 LCD but I do not know how to change the LCD interfacing program as the website uses two 16X1 LCD.

Anyway, thanks for your help.
 

lcd & microcontroller connection

Hi, look at Mazidi's book
Code:
 8051 microcontroller and embedded systems
You can find it in this forum by search or you can buy it.
It has an example about interfacing LCD's with microcontroller(8051).
 

hd44870 lcd and 8051 microcontroller interface

Then it is HD44870 as I suspected.
In that case all you have to do to go to the beginning of the second line is send a command to set the address to 40H. The rest of the code is unchanged.
 

Hi view this how-to. In the part 2 there are an example for 16x2 lcd with 16f84.
 

    scs83

    Points: 2
    Helpful Answer Positive Rating
The lcd connection must same with the program declaration.

There is two method to connection a lcd:

1. io connection. D0..D7, RS, WR, E is connected to io of microcontroller.
2. memory connection. The LCD is mapped into memory mapping in microcontroller.

thx
 

Hi, scs83,

I forgot one thing: you also need to tell the HD44780 during the initialization sequence (lcdinit routine) that there are 2 lines on the display.
Here is the modification to the original code:
================================================
; Finally,

; At this point, the normal 4 wire command routine can be used

;ldi wreg,0b00100000 ;Function set, 4 wire, 1 line, 5x7 font
;I commented out the previous line, which now becomes:
ldi wreg,0b00101000
rcall lcdcmd
================================================

The rest stays the same. And as I said previously, when you want to move to the second line you first need to set the DD RAM address to 40H. This can be done like this:

ldi wreg,0b11000000
rcall lcdcmd

One thing I noticed about this program is that id does not use equates. That makes modifications really awkward, because if the same constant is used in several places and you need to change it, then you have to chage it manually at all locations. If you forget one location, you can get a bug. It may not be ovious immediately, but it will show up eventually.
Therefore, take my advice: use equates. For example:
LCD_FSET EQU 0b00101000 ; LCD function set command
CRLF_CMD EQU 0b11000000 ; LDC CR+LF command (carriage return + line feed, for lack of a better definition; in fact this is what the command does, it returns the cursor to the beginning of second line)

With these, the modification to the code would read:

ldi wreg, LCD_FSET ; set LCD function to 4 wire interface, 2 lines, 5x7 char.

To start displaying on the second line, you would code:

ldi wreg, CRLF_CMD ; send CRLF command
rcall lcdcmd;

Now that is more readable, too, even without the comment. Should you find that you made a mistake when you defined CRLF (or other constant), all you need to do is change the EQU line and reassemble the program. The assembler will do the substitution for you at ALL locations, no misses.

One more thing: apparently this program uses a lot of hard-coded constants, including the number of characters per line, which means you may need to change that, too. Use EQU's.

Sorry for such a lengthy reply. I thought this might help.
Let me know if you have success with this.
 

Hi VVV,

Thanks for your reply but unfortunately I cant try it right now because I am currently on holidays. I will probably test the code before New Year. Can you check for me the code when I finished editing it?

Thanks
 

i think the best think is to communicate with the lcd with 6pin ( 4data / enable / rs ) the other you do not care........
 

Hi, scs83,

I never used this micro before, but sure I can take a look at the code.
 

Hi,

I need to clarify something. From this website, https://instruct1.cit.cornell.edu/courses/ee476/FinalProjects/s1999/sam/, I need to know the circuit diagram of this project. I have already connected the LCDs and keypads to the microcontroller. I have also connected the crystal oscillator. Is there anything I have missed out? Can somebody help me?

Thanks
 

you can also connect a reset circuit ...
try to take an final project as a reference, there are lots of designs on the web about connecting a 2-line lcd to an atmel controller. Look for example at **broken link removed**
It should be preety easy to adapt an working design ...
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top