Microcontroller › 8051 › 16*2 LCD displaying black boxes while interfacing with 8051
- This topic has 3 replies, 2 voices, and was last updated 10 years, 7 months ago by Ashutosh Bhatt.
-
AuthorPosts
-
April 19, 2014 at 4:53 am #3047Sunil HiremathParticipant
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 P1sbit 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 lcdwhile(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++);
}
}April 19, 2014 at 6:33 pm #11590Ashutosh BhattParticipanthave you connected pot on pin number 3 of LCD?
if no then connect it
if yes then vary it to change brightness
ur program seems to be correct
but you can test it on proteus simulator
April 20, 2014 at 4:04 pm #11602Sunil HiremathParticipantHi A M Bhatt,
yes, I ahve connected pot and I have checked varing it. but nothing difference.
and I don;t know about simulator.
Thank you
April 22, 2014 at 12:19 pm #11613Ashutosh BhattParticipantif u have connected pot correctly and even then ur brightness does not change then its a problem. brightness must change.
-
AuthorPosts
- You must be logged in to reply to this topic.