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 / JH162A LCD initialise problem with at89s52: Showing black box

JH162A LCD initialise problem with at89s52: Showing black box

|

Projects › Projects › JH162A LCD initialise problem with at89s52: Showing black box

  • This topic has 8 replies, 3 voices, and was last updated 13 years, 9 months ago by AJISH ALFRED.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • April 19, 2012 at 4:48 pm #4918
    bnbn qwe
    Participant

    I am doing a project : digital room thermometer. So , I have to interface LCD with 8051 microcontroller at89s52. But whenever I power up the microcontroller , LCD is lit but only black boxes are showing. I have tried many different codes and many things, but display is same . onle black boxes. But i have simulated this  circuit in proteus . here, that LCD is giving correct output. Plz help in determining the problem. Here are the attached code and circuit diagram.  Here is the C Code….
     
     
     
     
     
     
     
    //Program to test LCD. Display single character "A"
     
    #include<reg51.h>
    #define cmdport P3
    #define dataport P2
    sbit rs = cmdport^0;  //register select pin
    sbit rw = cmdport^1;  // read write pin
    sbit e = cmdport^6;  //enable pin
     
    void delay(unsigned int msec)  // Function to provide time delay in msec.
    {
    int i,j ;
    for(i=0;i<msec;i++)
    for(j=0;j<1275;j++);
    }
     
    void lcdcmd(unsigned char item)  //Function to send command to LCD
    {
    dataport = item;
    rs= 0;
    rw=0;
    e=1;
    delay(1);
    e=0;
    }
     
    void lcddata(unsigned char item)  //Function to send data to LCD
    {
    dataport = item;
    rs= 1;
    rw=0;
    e=1;
    delay(1);
    e=0;
    }
     
    void lcd_ini()     //Function to inisialize the LCD
    {
    lcdcmd(0x38);   
    delay(50);
    lcdcmd(0x0E);
    delay(50);
    lcdcmd(0x80);
    delay(50);
     
    }
    void main()
    {
    lcd_ini();
    lcddata('A');
    }
     
     
    April 19, 2012 at 4:58 pm #7506
    Mehtab Ali
    Participant

    you havent cleared lcd. it has previous data stored in it sometimes. please clear it by sending it 01 like ” lcdcmd(0x01);” also use a command “lcdcmd(0x06);” to shift the cursor to right.

    April 19, 2012 at 5:00 pm #7507
    Mehtab Ali
    Participant

    increase the delay from ” delay(50) to delay(250)”

    April 19, 2012 at 5:01 pm #7508
    bnbn qwe
    Participant

    i have simulated this in proteus. whenever  i give that clear command (01h) , nothing is displayed on simulator. but without it, simulator display is fine. But practically, that LCD is giving black boxes in lab.

    April 19, 2012 at 5:03 pm #7509
    Mehtab Ali
    Participant

    you try it using clear command and increase the delay as well. also you need to shift the cursor to right.

    April 19, 2012 at 5:11 pm #7510
    bnbn qwe
    Participant

    here is my modified code but nothing shows in simulator. 

     

     

     

    void lcd_ini()     //Function to inisialize the LCD
    {
    lcdcmd(0x38);   
    delay(250);
    lcdcmd(0x0E);
    delay(250);
    lcdcmd(0x01);
    delay(250);
    lcdcmd(0x06);
    delay(250);
    lcdcmd(0x80);
    delay(250);
     
     
    }
     
     
     
     
    and can you please clarify the use of delay duration in LCD. our test microcontroller is at89s52 and we are using crystal oscillator of 11.59 Mhz. is that frequency is related to lcd delay? how can i change the delay accordingly?
    April 20, 2012 at 12:47 am #7513
    Mehtab Ali
    Participant

    lcd requires some time to execute the commands so after a command we need to either give it a delay or we can check the busy flag.the crystal frequency is ok. in your program delay(250) is appropriate for lcd.

             i have run the c code and assembly code for lcd, and both displays data on lcd. you also check your connections.

     

    April 20, 2012 at 3:46 am #7514
    bnbn qwe
    Participant

    will try today and let u know after college

    May 4, 2012 at 5:52 pm #7587
    AJISH ALFRED
    Participant

    If nothing could be seen on the lcd, sometimes it happens because of over brightness. put a variable resistor in series with pin15 of the lcd, not less than 1k. Do the changes mentioned by Mehtab ali in his post. Try changing the resistance after running the code.

     

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

RSS Recent Posts

  • RC Electronic Speed Control Capacitors February 11, 2026
  • ANOTHER OLD PROJECT REDO February 11, 2026
  • XLR splitter to mono. February 11, 2026
  • CR2/CR123A Batteries In Projects February 11, 2026
  • Variable audio oscillator February 11, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 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