EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / 16*2 LCD displaying black boxes while interfacing with 8051

16*2 LCD displaying black boxes while interfacing with 8051

|

Microcontroller › 8051 › 16*2 LCD displaying black boxes while interfacing with 8051

  • This topic has 3 replies, 2 voices, and was last updated 11 years, 3 months ago by Ashutosh Bhatt.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • April 19, 2014 at 4:53 am #3047
    Sunil Hiremath
    Participant

    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++);
    }
    }

    April 19, 2014 at 6:33 pm #11590
    Ashutosh Bhatt
    Participant

    have 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 #11602
    Sunil Hiremath
    Participant

     Hi 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 #11613
    Ashutosh Bhatt
    Participant

    if u have connected pot correctly and even then ur brightness does not change then its a problem. brightness must change.

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Faulty heat air gun (dc motor) - problem to locate fault due to Intermittent fault [unrepairable] July 20, 2025
  • using a RTC in SF basic July 20, 2025
  • Dismantling a WestinghouseRoku TV ? July 20, 2025
  • Does US electric code allow branching ? July 20, 2025
  • My Advanced Realistic Humanoid Robots Project July 20, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise