4 Row-LCD problem

Beta Testing discussion on mikroC PRO for AVR.
Post Reply
Author
Message
CS
Posts: 357
Joined: 20 Dec 2005 23:30
Location: Germany

4 Row-LCD problem

#1 Post by CS » 07 Nov 2008 22:47

Hi all,

after testing the new software I wanted to display somethings on a 4 row LCD. Therefor I wrote the following code:

Code: Select all

// LCD module connections
sbit LCD_RS at PORTD.B2;
sbit LCD_EN at PORTD.B3;
sbit LCD_D4 at PORTD.B4;
sbit LCD_D5 at PORTD.B5;
sbit LCD_D6 at PORTD.B6;
sbit LCD_D7 at PORTD.B7;
sbit LCD_RS_Direction at DDRD.B2;
sbit LCD_EN_Direction at DDRD.B3;
sbit LCD_D4_Direction at DDRD.B4;
sbit LCD_D5_Direction at DDRD.B5;
sbit LCD_D6_Direction at DDRD.B6;
sbit LCD_D7_Direction at DDRD.B7;
// End LCD module connections

void main() 
{
  Lcd_Init();                                    // Initialize LCD
  Lcd_Cmd(LCD_CLEAR);                            // Clear LCD
  Lcd_Cmd(LCD_CURSOR_OFF);                       // Turn cursor off

  Lcd_Cmd(LCD_FIRST_ROW);
  Lcd_Out_CP("Here!");
  Lcd_Cmd(LCD_SECOND_ROW);
  Lcd_Out_CP("Hallo");
  Lcd_Cmd(LCD_THIRD_ROW);
  Lcd_Out_CP("Ein weiterer Test!!!");
  Lcd_Cmd(LCD_FOURTH_ROW);
  Lcd_Out_CP("Das ist die letzte Z");
  
  while(1)
  {

  }
}
Only the row 1 is right. All other lines show something, but not the things that I expect.

Please help.

Christian

Btw: Are there any limitations in this version?

yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

#2 Post by yo2lio » 08 Nov 2008 09:44

hello,

Can you try this :

Code: Select all

void main()
{
  Lcd_Init();                                    // Initialize LCD
  Lcd_Cmd(LCD_CLEAR);                            // Clear LCD
  Lcd_Cmd(LCD_CURSOR_OFF);                       // Turn cursor off

  Lcd_Out(1,1,"Here!");
  Lcd_Out(2,1,"Hallo");
  Lcd_Out(3,1,"Ein weiterer Test!!!");
  Lcd_Out(4,1,"Das ist die letzte Z");

  while(1)
  {

  }
}
Best regards, Florin Andrei Medrea.

http://www.microelemente.ro/
http://www.microelemente.ro/produse-si-servicii/
http://www.microelemente.ro/custom-software/

mail : florin@microelemente.ro

CS
Posts: 357
Joined: 20 Dec 2005 23:30
Location: Germany

#3 Post by CS » 08 Nov 2008 13:53

Thanks for the reply!

I've tried your code with the same result!

First line shows "Here!" -> ok
Second line starts at column 9 with "Ein weiterer" -> Should be line 3 start at column 1
Third line shows "Hallo" -> Should be line 2
Fouth line starts also at column 9 with "Das ist die" -> Right line but not complete and not the right start column.

What can I do?

Thanks

Christian

yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

#4 Post by yo2lio » 08 Nov 2008 14:19

Do you try to pus the same LCD with other MCU, like PIC ?

It's possible to have different address for the start row .
Best regards, Florin Andrei Medrea.

http://www.microelemente.ro/
http://www.microelemente.ro/produse-si-servicii/
http://www.microelemente.ro/custom-software/

mail : florin@microelemente.ro

David Prentice
Posts: 8
Joined: 30 Oct 2008 12:23

#5 Post by David Prentice » 08 Nov 2008 16:03

I can see no mechanism for telling the library the dimensions of your LCD. The two line models are all very straightforward: line 1 starts at RAM address 0, line 2 at 64.

You would expect the four line modules to start at 0, 32, 64, 96. However a 20x4 is 0, 64, 20, 84, and a 16x4 is 0, 64, 16, 80.

Most library code will have a function for setting the line layout, most often as a parameter to lcd_init(). There is no documentation for anything like this.

So you just need to write your own lcd_goto() function that just uses Lcd_Cmd(0x80 + y_address + x); You provide the correct y_address for the start of each line.

You also need to note that Lcd_Chr_Cp(c); from the Help system is wrong! It should be Lcd_Chr_CP(c);

You can just write all your LCD functions with the two primitives: Lcd_Cmd() and Lcd_Chr_CP()

David.

CS
Posts: 357
Joined: 20 Dec 2005 23:30
Location: Germany

#6 Post by CS » 08 Nov 2008 16:22

Ok,

@yo2lio: No, at this time I only use AVR because in my school we only use it with c. It seems that the Prof. doesn't like PICs.

@ David: I noticed the problem with the Lcd_Chr_CP(c). I will try to solve the problem like you describe.

Thanks

Christian

CS
Posts: 357
Joined: 20 Dec 2005 23:30
Location: Germany

#7 Post by CS » 08 Nov 2008 16:49

@ David: The display with wich I play around has:

line 1 address 0
line 2 address 20
line 3 address 40
line 4 address 60

Now it looks good!

Thanks again!

Christian

Post Reply

Return to “mikroC PRO for AVR Beta Testing”