Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

LCD displaying black boxes.

Status
Not open for further replies.

Sunil Hiremath

Newbie level 1
Joined
Jan 20, 2014
Messages
0
Helped
0
Reputation
0
Reaction score
0
Trophy points
0
Location
Bangalore
Activity points
0
Hi friends,

I'm interfacing JHD 162A 16*2 LCD with 89c51 Micro controller. I'm unable to display any character, it always displays half screen black boxes..
Need help....

I have given pin connection details and LCD test code below...

Tried with different MCU and LCD but same thing happening.


D0 - D7 pins of LCD = Port 1
RS = P3.5
R/W = ground
Enable = P3.4

//----------------------------------HEADER Declarations--------------------------------------//
#include <reg51.h>
#include <string.h>
//----------------------------------LCD Declarations--------------------------------------//
void initlcd(void);
void cmd_lcd(unsigned char command);
void data_lcd(unsigned char data2lcd);
void lcd_shortdelay(void);
void delay_ms(unsigned int ms);

#define CLR_LCD cmd_lcd(0x01); delay_ms(5)
#define RETURN_HOME_LCD cmd_lcd(0x02); delay_ms(5)
#define LCD_PORT P1

sbit enable=P3^4;
sbit regsel=P3^5;

void data_mode(void);

void printlcd(unsigned char *message, unsigned char row, unsigned char col);


//----------------------------------MAIN PROGRAM--------------------------------------//

void main(void)
{
initlcd(); //init lcd

while(1)
{

printlcd(" LCD TEST.. ", 0, 0); //print on lcd frist line
cmd_lcd(0x0C); //currsor off
delay_ms(1000);
CLR_LCD;
delay_ms(1000);
RETURN_HOME_LCD;
}
}

//----------------------------------LCD funtions--------------------------------------//

void initlcd()
{
enable=0;
delay_ms(20);
cmd_lcd(0x30);
delay_ms(5);
cmd_lcd(0x30);
cmd_lcd(0x30);
cmd_lcd(0x38);
cmd_lcd(0x08);
CLR_LCD;
cmd_lcd(0x06);
cmd_lcd(0x0e);
}

void cmd_lcd(unsigned char command)
{
LCD_PORT=command;
regsel=0;
enable=1;
enable=0;
lcd_shortdelay();
}

void data_lcd(unsigned char databyte)
{
LCD_PORT=databyte;
regsel=1;
enable=1;
enable=0;
lcd_shortdelay();
}

void printlcd(unsigned char *message, unsigned char row, unsigned char col)
{
cmd_lcd(0x80 + (0x40*row) + col);

for(; *message; message++)
data_lcd(*message);

}

void lcd_shortdelay(void)
{
unsigned char t=23;
while(t--);
}

void delay_ms(unsigned int ms)
{
unsigned char t1;
unsigned int t2;

for(t1=0; t1<ms; t1++){
for(t2=0; t2<711; t2++);
}
}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top