LCD module HD44780 does not 'remember' initialisation

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

Hello, I'm using LCD module compatible with HD44780 (SPLC780) and I'm using premade libraries to use it (attaching it to this post). The problem is that i want it to be initialised with cursor not visible, and when i write my program to microcontroller it is as it should be (the cursor is not visible) but when i power down my circuit and then power it up the cursor 'resets' to its ?default? initialization and cursor is blinking and its underlined.

Below is my program:

#define F_CPU 1000000UL
#include 
#include 
#include 
#include "lcd.c"
#include "ds18b20.c"
#include "buttons.c"
volatile uint8_t count=0;
/************************************************
   Define LCD connections and DS18B20 connections
   in ds18b20.h and lcd.h, initialize buttons with
   buttons_init()
*************************************************/

int main(void)
{
	DDRC|=_BV(PC4);
	PORTC&=~_BV(PC4);
	TCCR0=0b00000101;
	TIMSK=0b00000001;
	char UP,DOWN,LEFT,RIGHT;
	int hor=15,ver=1;
	buttons_init();
	LCDInit(LS_NONE);
	sei();
	while(1)
	{
		UP=(BTUP_PIN&_BV(BTUP_CON));
		DOWN=(BTDOWN_PIN&_BV(BTDOWN_CON));
		LEFT=(BTLEFT_PIN&_BV(BTLEFT_CON));
		RIGHT=(BTRIGHT_PIN&_BV(BTRIGHT_CON));
		LCDClear();
		if(UP==0)
		{
			PORTC|=_BV(PC4);
			++ver;
			if (ver>1) ver=0;
		}
		if(DOWN==0)
		{
			PORTC|=_BV(PC4);
			--ver;
			if (ver<0) ver=1;
		}
		if(LEFT==0)
		{
			PORTC|=_BV(PC4);
			--hor;
			if (hor<0) hor=15;
		}
		if(RIGHT==0)
		{
			PORTC|=_BV(PC4);
			++hor;
			if (hor>15) hor=0;
		}
		if((UP&&DOWN&&LEFT&&RIGHT)!=0)
		{
			PORTC&=~_BV(PC4);
		}
		LCDWriteString(tempBuf);
		LCDWriteStringXY(hor,ver,"X")
		_delay_ms(100);
	}
} 

ISR(TIMER0_OVF_vect)
{
	TCNT0=0b00000110;
	count++;
	if(count>3)
	{
		ds_conv();
		count=0;
	}
}

Just as I said, LCDInit(LS_NONE); should initialise LCD display with cursor not visible, right after programming mcu its like that, but when I power it down, and power it up again its back to flashing and underlined.

Why this happens? Is it LCD function fault, something is wrong with my LCD module? Maybe I initialise LCD in wrong place in my code.

Do you have any other tested LCD libraries ready to use if that's the problem?

Thank you very much for help in advance.

Attachment(s): 

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

Sounds like the LCD module needs more time to 'get ready' after a power-up.

When you program the MCU and then test, the LCD module is already powered-up and ready for commands.

When you power-down/power-up the LCD module probably needs to do a bit more work to get ready for commands.

Try a delay (1 sec or so to test with initially) before initializing the LCD to give it more time to start-up.

Hope this helps,
Guido

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

hehe

Had a similar problem when I added the On-Off button. Well, duh, after I've turned the display back on it needs initializing again.

(No, I didn't read your program. Too ADD for that.)

If you don't know my whole story, keep your mouth shut.

If you know my whole story, you're an accomplice. Keep your mouth shut. 

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

Thanks for answer GZijlstra, just tried it but unfortunatly it didnt worked.
I added delay of 1 sec before LCDinit and after LCDinit, then tried with 5 seconds.
As before, just after programming its like its meant to be, then i power it down, wait a while power it up. Then LCD top line is all white squares, bottom line is blank (not initialised) and then when initialisation happens cursor already appears blinking and underlined even if in code it is supposed to be not visible :/

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

I note that your "lcd.c" appears to come from ExtremeElectronics.

I advise that you use a library from a more reliable source. e.g. Fleury, Procyon, danni, ...

Simply call library functions according to their documentation. Everything will work painlessly !

David.

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

Quote:
I note that your "lcd.c" appears to come from ExtremeElectronics.

I advise that you use a library from a more reliable source. e.g. Fleury, Procyon, danni, ...

That is precisely the problem. Their library does not use the recommended 'Initialization by Instruction' procedure and will therefore not work reliably in many cases.

Specifically - the method they use may work if both the processor and the LCD controller are powered up simultaneously but it will almost certainly fail if the processor is reset without also removing and reapplying power to the LCD module.

If you do the opposite, remove and reapply power to the LCD module without also resetting the processor, then the LCD may initialize but only to the default state, a single line display with the default cursor.

Don

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

KonradIC13 wrote:
Then LCD top line is all white squares, bottom line is blank (not initialised)

This is your LCD's form of an error message. It means that you sent it a command it didn't recognize or that you did something silly like change R/S while En was high.

If you don't know my whole story, keep your mouth shut.

If you know my whole story, you're an accomplice. Keep your mouth shut. 

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

david.prentice wrote:
I note that your "lcd.c" appears to come from ExtremeElectronics.

I advise that you use a library from a more reliable source. e.g. Fleury, Procyon, danni, ...

Simply call library functions according to their documentation. Everything will work painlessly !

David.

Thanks ,that, ill search out those names tommorow for other LCD libraries to find something better and more proffesional

ps. where i can find danni LCD libraries or homepage? I found Procyon site and Peter Fleury's but cant find danni's

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

Doesn't sample code come with your toolchain (compiler)?

If I had to guess, your driver may not work the same with a "cold init" vs. a "re-init". It wasn't clear from a quick scan of the code whether it is a "timing" driver or a "busy flag" driver. In any case there is no return value from the init routine. You can still do a confirmation even if a timing driver by writing stuff to the LCD, and then reading back one (or more) characters from display memory and see if they match.

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

No LCD that I know about "remembers" its initialization. You HAVE TO initialize every time the LCD is newly powered up. Period.

Any initialization code will do it. The only trick is to understand WHEN the initializer needs to be called.

Jim

 

Until Black Lives Matter, we do not have "All Lives Matter"!

 

 

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

Quote:
Any initialization code will do it. The only trick is to understand WHEN the initializer needs to be called.

You have to use the correct initialisation procedure. e.g. the one set out in the data sheet.

Many readers are obsessed with inventing new initialisation sequences. Then whinge because their wrong sequence does not work.

Note that most hardware chips will have their own power-up defaults. For example, the HD44780 will start up in 8-bit mode.

Most MCU projects need 4-bit mode. You must use the correct sequence to enter 4-bit mode. You can re-initialise a running chip as often as you want. In practice, you only need to do this once at the start of your program.

David.

p.s. Yes, there are some undocumented sequences that do work on some chips. Our readers don't generally discover them!

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

Quote:

Thanks ,that, ill search out those names tommorow

Here you go: http://www.johanekdahl.se/rwiki/...

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

Thanks, i downloaded Peters F libraries and its working now.

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

Oh, cool.

(I really need to start using the 4 bit mode.)

If you don't know my whole story, keep your mouth shut.

If you know my whole story, you're an accomplice. Keep your mouth shut.