LCD 4x20 (SPLC780D) question

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

Hi there,

It's my first time I use a 4x20 character LCD.

My problem is that I can't find the cursor position for each line start position.

Can you help me?

Michael

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

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

Many 4x20 have character cell addresses like this (hex values):

00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13
40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53
14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27
54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 60 61 62 63 64 65 66 67

Here are portions of my function to set the 44780 DDRAM address from row and column

void LcdSetPosition( uint8_t row, uint8_t column)
{
	uint8_t addressInstruction = 0;
	if ((row == 2)||(row == 4)) {address += 0x40;}
	if ((row == 3)||(row == 4)) {address += 0x14;}
	addressInstruction += column - 1;
	addressInstruction |= (1<<7);

	// Here follows the transmission of the Set DDRAM Address command
	// It builds on other functions I have. You'll have to use your own
	// functions to accomplish this...

	// Wait for the Busy flag to clear
	LcdWaitBusy();

	// RS low for Instruction
	LCD_CTRL_PORT &= ~(1<<LCD_RS);

	// Send it!
	LcdSendByte(addressInstruction);
}

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

Actually my code is this:

(I use the IAR compiler)

/* for display line sellection */
const unsigned char LCD_LINE_1 = 0x00;
const unsigned char LCD_LINE_2 = 0x40;
const unsigned char LCD_LINE_3 = 0x14;
const unsigned char LCD_LINE_4 = 0x54;

#define SET_DD_RAM_ADDRESS 0x80

/* this is a string stored in flash */
__flash char LCD_ENTER_MENU[] = "PRESS ENTER FOR MENU";

void lcd_string(unsigned char line, char __flash *data){
lcd_command(SET_DD_RAM_ADDRESS | line);
while (*data != 0)
{
lcd_data (*data);
data++;
}
}

/* this is the call */
lcd_string(LINE_2, &LCD_ENTER_MENU[]);

My problem is that I cannot write to line 2 and 4, but only to 1 and 3. I have checked that I have set the 2 line support bit, when I initiate the module.

What is the problem?

Michael

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

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

There might be LCDs that address their character cells in another way. Do you have a data sheet for your display? Do You have a make/model number?

If you just send characters to the display endlessly, does the whole display fill up? If not then it is not properly initialized for 2 lines (second line being the physical lines 2 and 4).

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

I think that the character cells you defined match the LCD datasheet specs (that I use). As the datasheet says:

In two-line display (N = 1),
(aaaaaaa)2: (00)hex - (27)hex for the first line,
(aaaaaaa)2: (40)hex - (67)hex for the second line.

We are talking about the same LCD controller.

So where am I wrong????

Michael

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

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

Sigh... Again:

If you just send characters to the display endlessly, does the whole display fill up?
Or only the "physical lines" 1 and 3?

If the latter, then the display is not correctly initialized to two ("logical") lines.

I am asking you to do something like this (but your LCD functions are of-course not identical to mine - I am asking to do the equivalent of the sketched code that follows):

while (1) {
   LcdSendCharacter('X');
}

If the LCD is properly initialized this should fill the complete LCD with the character 'X'. If only physical line 1 and 3 is filled, then again it is not properly initialized for two "logical" lines.

Quote:
So where am I wrong????

We cant tell because we do not have your code and your setup. We are not claire-voyant or or posess ESP.

What we can do is help you with solving the problem, but you have to do the legwork. Do that experiment, and only then return here with the result, instead of essentially repeating "Where am I wrong?".

The general lesson is: Often fault-seeking is about dividing the problem space. You form a hypothesis (in my case the "not initialized properly" hypothesis). You then devise a test that is "sturdy" enough that you are fairly certain that it will test the hypothesis correctly. Depending on the outcome you then move on to another hypothesis.

If you see only lines 1 and 3 filled, you need to debug the init. If all four lines are filled we need to look elsewhere.

Go make that test.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

JohanEkdahl,

Ok, I will follow your suggestions. Also today I will connect another display same type, but different manufacturer.

Yesterday night, I did what you said. I was sending a string like "Hallo" (Ok, today I will send only one char). There was no fill at the 2 and 4 lines, but only at 1 and 3.

I will come back with new results.

Thanks for your time,

Michael

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

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

Quote:

There was no fill at the 2 and 4 lines

Then there is no need to try my suggesntion with only one character. If repeated writes of "Hallo" did not eventually occur on physical line 2 and 4 then your display is not correectly initialized for 2 logical lines.

Show us the code where you do the initialization, please.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

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

Hi there,

I found the problem. There wasa library definition that defines the CPU clock in order to make the timing calculations. There was wrong frequency set there, so the timing was bad. There was no problem at the delays of the functions, but only to the LCD Enable Toggle delay time.

When I fixed it everything was well.

My question is why the display worked well as a 1 line module?

Anyway, my problem is fixed.

Very thanks for your time and suggestions.

Michael

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

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

Quote:

My question is why the display worked well as a 1 line module?

One possible explanation:
Due to timing constraints the instruction before the one that sets 2 lines was not finished when the 2-lines-instruction was sent. In that situation the LCD simply ignores the instruction and thus it was never executed.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]