Electronic – Hitachi HD44780 LCD works exactly 50% of the time


My Hitachi LCD works 50% of the time. Is it a problem is a deboucing reset button issue on the AVR?
Why is this happening?
Here's a video of what is happening.

This does not happen if I write on the 1st line of the LCD only.
It only happens if I write on the 2nd line of the LCD. It looks like memory address problem, but I reset the memory with clear display on every init.

I've also tried to increment the delay time (5 seconds before the init). Didn't work.

Here my INIT():

    _delay_ms(15); //wait for VDD to rise

send_nibble(0,0b0010);   //Set to 4 bit operation (note: 1 nibble operation)

send_nibble(0,0b0010);   //Function set, 4 bit

send_nibble(0,0b0000);   //Clear Display

send_nibble(0,0b0000);  //Entry Mode, Increment cursor position, No display shift

send_nibble(0,0b0000);   //Display ON, Cursor On, Cursor Blinking

Best Answer

It looks like you're resetting your microcontroller, but the display is not resetting (when you press the button the display does not turn off/reset). Note that without a reset, you are starting in 4-bit mode, to send 8-bit commands you need to switch back to that mode.

In this case, the first thing your init should to is reset the display to a known state. Alternatively, you can just wire the display to reset with the same signal as the microcontroller reset.

For proper initialization look at the datasheet. Notice the initialization diagram in the datasheet starts with "Power On". You're not starting there, you're skipping the first couple steps. According to the datasheet,

If the power supply conditions for correctly operating the internal reset circuit are not met, initialization by instructions becomes necessary.

This is the 4-bit initialization by instruction diagram.

enter image description here