Problem with the second line of a 2x16 lcd

Go To Last Post
13 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi gays,
I use an atmega32 on the stk500 board and I program that with codevision.
I use the lcd.h that I found in the program.
The lcd is ssc2b16dlgy-h
The program is the following

#asm
   .equ __lcd_port=0x18 ;PORTB
#endasm

char lcd_test [16];

void main(void) 
{

sprintf(lcd_test," test");
lcd_init(16);

while (1)
      {
lcd_clear();
lcd_gotoxy(0,1);
lcd_puts(lcd_test);
delay_ms(100);
       }
}

but I can't see anything on the lcd.
For the conection I do exactly what the program says to do.
RS (pin4) ------ bit 0
RD (pin 5) ------ bit 1
EN (pin 6) ------ bit 2
DB4 (pin 11) --- bit 4
DB5 (pin 12) --- bit 5
DB6 (pin 13) --- bit 6
DB7 (pin 14) --- bit 7

Another thing is that i can't find any ware the code I have to send to the lcd in 4bit to print to the lcd the letters I want with the _lcd_write_data();

Can anyone tell me if there is any other library that I can use?

And how can I put an other library in code vision?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm not a CV user, so I don't know how far the library goes in initializing the display. But my guess would be "not far" unless you are feeding parameters to the wizard to generate the appropriate init sequence, which is hidden. Otherwise I'd say you are missing a bunch of init lines.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sakis_1:

I don't know anything about Codevision but I do have a suggestion about a troubleshooting technique that may help you figure out what is going on and from there how to fix it.

The implication of your topic heading is that the first line works ok but the second line doesn't. This means that the wiring is probably ok and there could be an initialization problem or an addressing problem.

Write a simple program that sends 80 successive printable ASCII codes to the LCD. I usually start with "!" (0x21). This will put a displayable ASCII code in each DDRAM address on the LCD module and therefore something should show up in each character location on the display.

Take a look at the LCD Addressing information at http://web.alfredstate.edu/weimandn for an explanation of which of the characters you should and should not see.

Don

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

1) The CV library works just fine with a wide variety of LCDs and VFDs that I've applied over the years.

2) There is a return value from lcd_init() -- use it.

3) For normal operations, there is no need to invoke _lcd_write_data. There are some exceptions but not needed for "hello world".

4) Have you disconnected your ISP from port B pins?

5) Is your cable short and with good signal integrity? A ratty E line will cause problems, but usually not a total failure.

Quote:

but I can’t see anything on the lcd.

6) If you cannot see the top line of all black boxes when the LCD is uninitialized, then your contrast is way off, and you will never see anything regardless of what driver or library that you use. Test this by holding the AVR in reset during power-up.

7) LCDs are slow to power up. Put a delay at the start of the program, and/or reset the AVR after power-up for a fresh try.

Quote:

And how can I put an other library in code vision?

8) As outlined in the manual/Help?

Quote:

Can anyone tell me if there is any other library that I can use?

9) Sure; lots of them. But if you can't see the black boxes then it is not going to help. And if you can't get the proven CV LCD.lib to work I don't know how another would help you.

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

when i use the first line every think works fine.
with the _lcd_write_data i want to put in my program the cursor in the end of a word.
i want to put a "password:" in the first line and the numbers in the second.
if i put all of them in the first line every think is good.
the problem is at the second line only.
i had tried to put the lcd on the other ports too but i had the same problem.
is there any way to find out if my lcd isn't working with two lines in 4bit mode?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

is there any way to find out if my lcd isn't working with two lines in 4bit mode?


Check the datasheet to see what the memory addresses are for line 1 and line 2.

Yes, for cursor control you may well want to use write_data. You might try something like this.

//
// **************************************************************************
// *
// *		C U R S O R _ O N
// *
// **************************************************************************
//
//
#define	LCD_CONTROL	0x08
#define	LCD_DISPLAY	0x04
#define	LCD_CURSOR	0x02
#define	LCD_BLINK	0x01

#define	LCD_CURSOR_ON	(LCD_CONTROL | LCD_DISPLAY | LCD_CURSOR | LCD_BLINK)
#define	LCD_CURSOR_OFF	(LCD_CONTROL | LCD_DISPLAY)

void						cursor_on			(unsigned char col, unsigned char row)
{
	lcd_gotoxy(col, row);
	_lcd_ready();
	_lcd_write_data (LCD_CURSOR_ON);

}
//
// **************************************************************************
// *
// *		C U R S O R _ O F F
// *
// **************************************************************************
//
//
void						cursor_off			(void)
{
	_lcd_ready();
	_lcd_write_data (LCD_CURSOR_OFF);

}

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It took some digging to find a datasheet, but it appears that line 2 is at the "standard" address of 0xc0 so everything should work swimmingly.

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sakis_1:

Quote:
is there any way to find out if my lcd isn't working with two lines in 4bit mode?

This is precisely what my previous post was all about.

If you put a displayable character in each of the LCD's memory locations then a character should show up in each of the display positions. If characters show up on the second line then you know that the LCD is properly initialized and the second line works. This means that it is a programming (addressing) issue.

Don

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

an other way to find out if your second line is available ( and i do not see any reason why not ) is to start at ram location 0, put the character A in it and fille the entire ram with this character. What will happen is a rapid fill of the first line then a short pause and the the rapid filling of the second line.
Now you know that you should be able to write to the second line.

now all you have to do is find out at what exact adress the second line starts. BUt in the previous posts this has already been given, so that should not be a big problem.

regards

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

meslomp:

Quote:
put the character A in it and fille the entire ram with this character

Not exactly. By putting a different character in each ram location you can not only tell whether the second line is working but you can also determine what addresses are being used. Follow the link in my first post for more information.

Don

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Not exactly. By putting a different character in each ram location you can not only tell whether the second line is working but you can also determine what addresses are being used.

Yes you can - use ASCII printable characters and you can identify the address used from the character shown (you may need to refer to your ASCII chart and because it's only 32..127 that are displayable you may need to "borrow" some non-ASCII from beyond 127 to make up the 0x80 possibilities)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My idea was first fill the entire ram with A's to let the Op see that he can adress the entire display...

then let him find the correct adress by writing every 10th location with a number then he would have known what adress to use to adress the second line.....

after re-reading your post you could also use your method to find out the correct adress.

regards

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Clawson:

Quote:
... and because it's only 32..127 that are displayable you may need to "borrow" some non-ASCII from beyond 127 to make up the 0x80 possibilities)

The printable ASCII characters start with 32 and go to 127. This gives you 95 printable characters except that the first one is a [space] which is why I suggested starting with 33 (0x21).

You mention 0x80 possibilities and I think you are referring to the 80 (decimal) DDRAM locations which would be 0x50 if you prefer counting in hex.

Everyone:
For more information on these topics you might want to check out http://web.alfredstate.edu/weimandn. Use the LCD Addressing link for an explanation of the DDRAM setup and how it relates to the display. Use the ASCII chart or Decimal - Binary - Octal - Hex - ASCII Conversion Chart link for YAAC (yet another ASCII chart).

Don