Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

LCD doesn't Initialize in 4-bit mode

Status
Not open for further replies.

motif

New Member
Hi All,

From last couple of weeks I am trying to get my LCD JHD162A initialized in 4-bit mode but no success. In default 8-bit mode it seems to be working fine.

I did below experiment to verify that 8-bit mode works fine.
After power-up (default 8-bit), as a part of initialization I just send instruction 0x0F to enable display and then I send data bytes. With this I get what is shown in LCD_init.png (in 8-bit mode). With this it appears that there is no connection related issue between micro-controller and LCD.

Problem comes when I try it for 4-bit mode. I have almost tried all permutation and combinations but it never moves into 4-bit mode. Delay specified in code are in seconds and whole program takes 2-3 minutes to execute.

I have also put large (330uf) cap between power-gnd LCD pins to avoid reseting of LCD and going to default mode due to spikes (which I was not expecting).

In this mess I even tried replacing LCD, but observed same behavior with another one.

I am following JHD162A.pdf and HD44780U which people say compatible with JHD162A displays. I am not sure!!!

I have reduced the code to do initialization and print some characters. The initialization is controlled by define //#define INIT8BIT. If this define is present, it will initialize in 8-bit mode (just enabling display) else in 4-bit mode.

I didn’t want to re-invent the wheel and also tried drivers present open-forums, but they didn’t work (e.g Flex LCD driver).

Feel free to ask any other information required, I can re-check anything doubtful. Attaching required code and schematic.

I will really appreciate if people can provide some directions. I am totally lost here..

Regards,
Sandy


## Attached LCD_files.zip contains code, connections and output image.

Here are more details..

LCD : JHD162A
Vcc : 3.30 V
Vee : Grounded.
micro-controller : 16LF727
clock : Internal oscillator.

Pin connections :
#define LCD_DB4 PIN_A3
#define LCD_DB5 PIN_A4
#define LCD_DB6 PIN_A5
#define LCD_DB7 PIN_E0

#define LCD_RS PIN_A0
#define LCD_RW PIN_A1
#define LCD_E PIN_A2

////// debug LEDS
#define GREEN_LED PIN_A6
#define RED_LED PIN_A7
 

Attachments

  • LCD_files.zip
    30.5 KB · Views: 180
One thing jumps out real fast that LCD is not make to work a 3.3 volts

LCD : JHD162A
Vcc : 3.30 V
Vee : Grounded.
micro-controller : 16LF727
clock : Internal oscillator.
And the second thing which is why it's not working is that datasheet doesn't say it can be used in four bit mode
only eight bit. It doesn't list any commands to set 4 bit mode. https://www.datasheetarchive.com/JHD162A-datasheet.html

It only tell you that data transfer is 8 bit
 
Ian the data sheet for the LCD said it's min voltage is 4.5. And like I said it doesn't say any thing about 4 bit mode only thing it tells you is the LCD is intended for 8 bit mode.
And if you google the LCD you'll see no one has has any luck getting it to work in 4 bit mode.

Well there are some that work in 4 bit mode but the code is using the RW pin to check the busy signal.

And in 8 bit mode there not as pickie.
 
Last edited:
If voltage is the issue then it shouldn't have even worked for 8-bit mode. As shown in LCD_init.png it is working correctly with 8-bit mode, only because 4 LSB bits are open-ed it is printing weird characters. But again those weird characters are as per data-sheet.

If checked with multimeter that RA4 swings to 3.3v and 0v. May be for this device it is not open collector.

I also some time feel that this device doesn't support 4-bit mode, but below link challenges me again and again

https://iamsuhasm.wordpress.com/tutsproj/using-lcds/

Regards,
Sandy
 
What is the time delay between sending successive nibbles?
 
There's one thing to think about in 8 bit mode delays don't matter as much long as you set the e and rs right and hold the pin state.
And to a LCD is like a capacitor, cels have longer time to charge in 8 bit mode.

And from what I have been reading the chip in these are not all the same.

1 person posted he has a 100 of them and he couldn't get 1 to work in 4 bit mode till he started using the RW pin to check the busy flag and the
thing also needed to be reset in code if the power is no all the time
 
Finally got my LCD working with 4-bit mode.

Issue was with operating voltage, JHD162A doesn't work with 3.3V (for 4-bit), it needs 5V.

Sorry Burt, partially working LCD at 3.3V gave me illusion that probably this device supports 3.3V.

Working Init sequence is also bit different..

####### LCD Init #######

delay_ms(200);
lcd_send_nibble(0x20);
delay_ms(200);
lcd_send_byte(0x28);
delay_ms(200);
lcd_send_byte(0x01);
delay_ms(200);
lcd_send_byte(0x06);
delay_ms(200);
lcd_send_byte(0x08);
delay_ms(200);
lcd_send_byte(0x0F);
delay_ms(200);

############

Thanks Burt and Everyone..

Regards,
Sandy
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top