Does LCD display anything?

Thread Starter

corefinder

Joined Oct 6, 2011
55
Hi everyone,
I was interfacing lcd JHD162a with AT89S52 atmel microcontoller. I made a code and burned in the processor but LCD didn't display anything. According to the code it should initialise lcd and cursor must be blinking. I made the program in micro proc for 8051 by Microelectronika.
Rich (BB code):
sbit LCD_RS at P2_0_bit;
sbit LCD_EN at P2_1_bit;

sbit LCD_D4 at P2_4_bit;
sbit LCD_D5 at P2_5_bit;
sbit LCD_D6 at P2_6_bit;
sbit LCD_D7 at P2_7_bit;
// End Lcd module connections
void main()
{
  Lcd_Init();                       // initialise lcd
  Delay_ms(100);                    // command Lcd
  LCD_EN=0;
  LCD_RS=0;
  LCD_D4=0;
  LCD_D5=0;
  LCD_D6=0;
  LCD_D7=0;
  LCD_EN=0;
  Delay_ms(500);
  LCD_EN=1;
  Delay_ms(100);
  LCD_D4=1;
  LCD_D5=1;
  LCD_D6=1;
  LCD_D7=0;
  LCD_EN=1;
  Delay_ms(500);
  LCD_EN=0;
  }
I want to know whether problem is in the program or lcd is faulty.So if any of you have access to these devices kindly check the code provided and see if lcd is displaying lcd. I have attached its hex file and datasheet of lcd.
 

Attachments

t06afre

Joined May 11, 2009
5,934
I see some thing here. You must add a variable resistor for contrast adjustment like shown in the picture. Also if you want to use 4 bit interface. You must copy the flowchart on page 10 in the datasheet exactly. That is VERY important. So far you have not done that.
 

Attachments

Thread Starter

corefinder

Joined Oct 6, 2011
55
You must copy the flowchart on page 10 in the datasheet exactly. That is VERY important. So far you have not done that.
That flowchart is about initialization of LCD I used a function Lcd_Int() int the code. It calls the already defined function by compiler ,the function automatically initializes LCD which have all HD4470 compliant controllers.
SO it should not be a problem. Also i write code exaclty like one in flowchart but that is also not working!!
This is what I got from flowchart please tell if I did any error.
Rich (BB code):
void Lcd_Init1()
{
LCD_RS=0;
LCD_EN=0;
Delay_ms(50);
LCD_D4=0;
LCD_D5=0;
LCD_D6=0;
LCD_D7=0;
LCD_D4=1;
LCD_D5=1;
LCD_EN=1;
Delay_ms(10);
LCD_EN=0;
Delay_ms(50);
LCD_EN=1;
Delay_ms(10);
LCD_EN=0;
Delay_ms(200);
LCD_EN=1;
Delay_ms(10);
LCD_EN=0;
Delay_ms(100);
LCD_D4=0;
LCD_D5=1;
LCD_EN=1;
Delay_ms(10);
LCD_EN=0;
Delay_ms(10);
LCD_D4=0;       /* d4=0,d5=1 next d7=1 */
LCD_D5=1;
LCD_EN=1;
Delay_ms(10);
LCD_EN=0;
LCD_D5=0;
LCD_D7=1;
LCD_EN=1;
Delay_ms(10);
LCD_EN=0;
Delay_ms(10);
LCD_D4=0;    /* next cycle*/
LCD_D5=0;
LCD_D6=0;
LCD_D7=0;
LCD_EN=1;
Delay_ms(10);
LCD_EN=0;
LCD_D7=1;
LCD_EN=1;
Delay_ms(10);
LCD_EN=0;
Delay_ms(10);
LCD_D4=0;  /*next cycle*/
LCD_D5=0;
LCD_D6=0;
LCD_D7=0;
LCD_EN=1;
Delay_ms(10);
LCD_EN=0;
LCD_D4=1;
LCD_EN=1;
Delay_ms(100);
LCD_EN=0;
Delay_ms(10);
LCD_D4=0; /*last cycle*/
LCD_D5=0;
LCD_D6=0;
LCD_D7=0;
LCD_EN=1;
Delay_ms(10);
LCD_EN=0;
LCD_D4=1;
LCD_D5=1;
LCD_D6=1;
LCD_D7=0;
LCD_EN=1;
Delay_ms(10);
LCD_EN=0;
Delay_ms(100);
}
 

MrChips

Joined Oct 2, 2009
34,812
Is the contrast connection (pin-3) correctly connected to a contrast potentiometer (or at least with a 1kΩ resistor to GND)?

When you first apply power do you get black rectangles on the display?
 

Thread Starter

corefinder

Joined Oct 6, 2011
55
Is the contrast connection (pin-3) correctly connected to a contrast potentiometer (or at least with a 1kΩ resistor to GND)?

When you first apply power do you get black rectangles on the display?
Yes I have put varistor to pin-3 and when I reduce resistance I see black boxes only in 1st row.
 

spinnaker

Joined Oct 29, 2009
7,830
What have you done to troubleshoot your problem?

Step through your code with the debugger. When you get to the place where data is output to the LCD. Veirify with scope, logic analyzer, logic probe or DMM that you see the correct data at the LCD pins.

If that is all correct then the next step is to look at timing.

The two main issues with LCD are contrast pin already mentioned and timing.
 
Top