0
\$\begingroup\$

I'm new to electronics. I'm trying to interface my lcd with an avr but I don't think my code is initialising the lcd properly.

At the top of header file for the library am using, I have this

define LCD_LINE_LENGTH 0x40

Am told by the manual that this might need to be changed. It's not blindingly ovious in the data sheet for beginners.

Here's the link to the datasheet:

http://uk.rs-online.com/web/search/searchBrowseAction.html?method=getProduct&R=7200235 What does it mean and where is it stated in ds

\$\endgroup\$
  • \$\begingroup\$ Is the library source code available online anywhere? \$\endgroup\$ – jpc Mar 26 '11 at 12:31
1
\$\begingroup\$

Line width is the number of characters that can be displayed on one line. In the description section, the datasheet says:

The maximum display size can be either 80 characters in 1-line display or 40 characters in 2-line display.

\$\endgroup\$
  • \$\begingroup\$ @Ageis: note that the 0x40 is a hexadecimal value, decimal 64. For an 80 character display you change this value to "80" or "0x50". For a 40 character display that's "40" or "0x28", resp. \$\endgroup\$ – stevenvh Mar 26 '11 at 16:50
0
\$\begingroup\$

LCD modules that are compatible with HD44780 (which the datasheet says it is) have 80 bytes of display RAM. The same controller can be used to drive displays anywhere from 8x1 up to 20x4 (and even larger if two or more controller chips are present).

On different sized multi-line displays, the memory address of the start of each line is different.

A 16x2 display typically has line 0 at 0, and line 1 at address 40. The extra RAM addresses that are not visible on screen can be used for scrolling, by changing the memory address that corresponds to the first column.

A 20x4 display probably has the lines starting at 0,20,40,60 but consult the datasheet to be sure. You'd probably need to set the line length to 20 in your driver, therefore. (Hard to say without seeing source code to the library).

\$\endgroup\$
  • \$\begingroup\$ Actually, I think a 20x4 display is likely to have line offsets of 0, 64, 20, and 84 (decimal) or 0x00,0x40,0x14, and 0x54 (hex), in that order. Electrically, most 20x4 displays are wired as a 40x2 with the right half cut off and moved to the bottom. The top half of the display acts like the left 20 columns, and the bottom half as the right 20 columns. \$\endgroup\$ – supercat Jul 22 '11 at 17:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.