four bit HD47780 troubles

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

i was pretty pleased with my self when i got my 20x4 lcd working in 8-bit mode last night..
i'm not having as much luck tonight..

i'm using a tiny2313 and winAVR. PORTB controls the data pins, and bits 4, 5, and 6 of port D are the RS, R/W, and Enable lines.

i've been refering to these documents:
http://www.myke.com/lcd.htm
http://www.doc.ic.ac.uk/~ih/doc/...

I haven't changed anything in hardware, all data pins are still connected. my results vary from random oo's and arrows, to blank screens, to nothing at all ( just the black bars) and there doesn't seem to be a pattern..

i'm not sure if i'm sending my nibbles correctly, i should send the MSB on the portB pins 4-7, and then the LSB on the same pins, correct?

i've attached my code, any pointers would help

Attachment(s): 

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

If you want 4-bit mode you should send first the 4 MSB and then the 4 LSB.
I'll attach part of my c-code for cv for init:

//Function for initializing the display..
void LCD_Init()
{
    LCD_Port_DDR=0xFF;          //Set LCD Port as output..
    delay_ms(15);
    LCD_Write(0x22,0);          //Init in 4-bit mode..
    delay_ms(5);
    LCD_Write(0x22,0);          //Init in 4-bit mode..
    LCD_Write(0x28,0);          //LCD has more than 1 lines..
    LCD_Write(0x0C,0);          //Turn the display on,the cursor off..
    LCD_Clear();                //Clear the display..
    LCD_Write(0x06,0);          //Set the cursor move direction and enable the display.. 
}

and something else:
Try instead of this:

send_string("blue");

this:

send_string('b','l','u','e');

HTH
Kostas

It's better to keep your mouth shut and think you a fool, than open it and move out the doubts!

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

Ummmm... It seems You attached the eight bit version of Your code. Please re-post.

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

Also note that sometimes an LCD will sometimes, before they're placed in 4 bit mode, take the 4 LSBs of an init command as a completely new command and get confused. This only applies for the first two commands in the init sequence, when the LCD still thinks it's talking 8 bit.

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

Quote:

Also note that sometimes an LCD will sometimes, before they're placed in 4 bit mode, take the 4 LSBs of an init command as a completely new command

If You are implying that the 4-bit initialization starts with sending eight bit commands in two consecutive nibbles (5-bit chunks) then this is wrong. The 4-bit init starts with sending the MSBs (bits 7..4) of three 8-bit commands to the 44780. The four LSBs (bits 3..0) should not be sent at all. Only when the controller has been properly placed in 4-bit mode should 8-bit commands be sent in two consecutive nibbles.

My two favourite 44780 documents have been attatched in this thread: https://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=116409#116409 . There are excellent flowcharts and more on how to initialize the 44780 properly.

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 JohanEkdahl, I just donwloaded your favourite 44780 documents and it help me, thanks and one more question, in 4 bit mode, do I need connect D3-D0 (bits 3...0) to the ground or can leave unconnected?

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

You have to leave them unconnected according to the HD44780 specs.

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

Ok, thanks

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

I have my DB3..0 unconnected, but there has been discussions here indicating that some people has had success when grouding them rather than leaving them unconnected.

If Your display works whith DB3..0 unconnected then leave it that way.

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]