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
You are here: Home / Topics / 4bit lcd program for 2148…..i am getting perfectly output in kiel but in proteus nothing is displaying on lcd..can you tell me

4bit lcd program for 2148…..i am getting perfectly output in kiel but in proteus nothing is displaying on lcd..can you tell me

|

Projects › Projects › 4bit lcd program for 2148…..i am getting perfectly output in kiel but in proteus nothing is displaying on lcd..can you tell me

  • This topic has 6 replies, 2 voices, and was last updated 9 years, 2 months ago by ANJUSHA.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • June 9, 2013 at 6:06 am #2472
    ANJUSHA
    Participant

    #include <LPC21xx.H>
    void delay(int count ) ;
    void lcddata(int c);
    void lcdcmd(int t);

    void delay(int count)
            {
            int j=0, i=0;
            for (j=0;j<count;j++)
            for (i=0;i<250;i++);
            }

     

    void lcdcmd(int t)
    {
     
    int s=0;
    s=(t>>4) & 0x0f;
    s=s << 16;
     
    IO1CLR=0x10000000; // rs =1 p1.28
    IO1CLR=0x20000000; // rw =0 p1.29
    IO1SET=0x40000000;

    IO1CLR=0X000F0000;
    IO1SET = s;
    delay(1000);
    IO1CLR=0x40000000; //en=0 p1.30
     
    s = t & 0x0f;
    s=s<<16;

    IO1CLR=0x10000000; // rs =1 p1.28
    IO1CLR=0x20000000; // rw =0 p1.29
    IO1SET=0x40000000;

    IO1CLR=0X000F0000;
    IO1SET = s;
    delay(1000);
    IO1CLR=0x40000000; //en=0 p1.30
    }

    void lcddata(int c)
    {
    int d=0;
    d=((c>>4) & 0x0f);
    d= d<<16;
     
    IO1SET=0x10000000; // rs =1 p1.28
    IO1CLR=0x20000000; // rw =0 p1.29
    IO1SET=0x40000000;

    IO1CLR=0X000F0000;
    IO1SET = d;
    delay(1000);
    IO1CLR=0x40000000; //en=0 p1.30
     
    d= c & 0x0f;
    d=d<<16;

    IO1SET=0x10000000; // rs =1 p1.28
    IO1CLR=0x20000000; // rw =0 p1.29
    IO1SET=0x40000000;

    IO1CLR=0X000F0000;
    IO1SET = d;
    delay(1000);
    IO1CLR=0x40000000; //en=0 p1.30
    }

    void msgdisplay(unsigned char k[])
    {
    int i;
    for(i=0; k!=’’; i++)
    {
    lcddata(k
    );
    delay(1000);
    }
    }

    int main( )
    {
    IO1DIR=0X700f0000;
    delay(100);

    lcdcmd(0x02);
    lcdcmd(0x28);
    lcdcmd(0x01);
    lcdcmd(0x06);
    lcdcmd(0x0E);

    while(1)
    {
    lcdcmd(0x80);
    msgdisplay(“INFORMATION”);
    delay(1000);
    lcdcmd(0xc0);
    msgdisplay(“lab”);
    delay(1000);
    }

    }

    June 9, 2013 at 6:15 pm #9920
    AJISH ALFRED
    Participant

    Hi Abiram,

    “i am getting perfectly output in kiel”.

    KEIL is an IDE used for compiling code, sometimes burning the code and simulate the microcontroller registers. I can’t understand what exactly you mean by ‘getting perfect output on kiel’. Please clarify it and tell us more details about your project so that we can help you better.

    June 10, 2013 at 12:55 am #9923
    ANJUSHA
    Participant

    #include <LPC21xx.H>
    void delay(int count ) ;
    void lcddata(int c);
    void lcdcmd(int t);

    void delay(int count)
            {
            int j=0, i=0;
            for (j=0;j<count;j++)
            for (i=0;i<250;i++);
            }

    void lcdcmd(int t)
    {
     
    int s=0;
    s=(t>>4) & 0x0f;
    s=s << 16;
     
    IO0CLR=0x10000000;    // rs =0 p0.28
    IO0CLR=0x20000000;    // rw =0 p0.29
    IO0SET=0x40000000;

    IO1CLR=0X000F0000;
    IO1SET = s;
    delay(1000);
    IO0CLR=0x40000000; //en=0 p0.30
     
    s = t & 0x0f;
    s=s<<16;

    IO0CLR=0x10000000;    // rs =1 p0.28
    IO0CLR=0x20000000;    // rw =0 p0.29
    IO0SET=0x40000000;

    IO1CLR=0X000F0000;
    IO1SET = s;
    delay(1000);
    IO0CLR=0x40000000; //en=0 p0.30
    }

    void lcddata(int c)
    {
    int d=0;
    d=((c>>4) & 0x0f);
    d= d<<16;
     
    IO0SET=0x10000000;    // rs =1 p0.28
    IO0CLR=0x20000000;    // rw =0 p0.29
    IO0SET=0x40000000;

    IO1CLR=0X000F0000;
    IO1SET = d;
    delay(1000);
    IO0CLR=0x40000000; //en=0 p0.30
     
    d= c & 0x0f;
    d=d<<16;

    IO0SET=0x10000000;    // rs =1 p0.28
    IO0CLR=0x20000000;    // rw =0 p0.29
    IO0SET=0x40000000;

    IO1CLR=0X000F0000;
    IO1SET = d;
    delay(1000);
    IO0CLR=0x40000000; //en=0 p0.30
    }

    void msgdisplay(unsigned char k[])
    {
    int i;
    for(i=0; k!=’’; i++)
    {
    lcddata(k
    );
    delay(1000);
    }
    }

    int main( )
    {
    PINSEL1=0X00000000;
    PINSEL2=0X00000000;
    IO0DIR=0X70000000;
    IO1DIR=0X000f0000;
    delay(100);

    lcdcmd(0x02);
    lcdcmd(0x28);
    lcdcmd(0x0c);
    lcdcmd(0x06);
    lcdcmd(0x01);

     

    while(1)
    {

    msgdisplay(“INFORMATION”);
    delay(1000);
    //lcdcmd(0xc0);
    //msgdisplay(“HYDERABAD”);
    //delay(1000);
    }

    }

    June 10, 2013 at 12:58 am #9924
    ANJUSHA
    Participant

    June 10, 2013 at 1:07 am #9925
    ANJUSHA
    Participant

    hello sir

          i  included the code i written for 4-bit lcd…i mean to say that i can observe ,whethet that pin is getting data as per program,on peripheral window of port0 and port 1..and again i tested using proteus….choosing microcontroller and 16×2 lcd..output is not getting.just lcd contrast light is glowing.no cursor blinking….sir can u check whether initial commanda for 4_bit lcd are correct? and solve this problem sir…i wi be thankful to you.

    June 11, 2013 at 1:04 pm #9945
    AJISH ALFRED
    Participant

    Hi,

    The initial commands for the 4 bit interfacoing should be something like the following; don’t forget to add some delay after all the commands.

     

        lcd_cmd ( 0x02 ); // to initialize LCD in 4-bit mode.
        lcd_cmd ( 0x28 ); //to initialize LCD in 2 lines, 5X7 dots and 4bit mode.
        lcd_cmd ( 0x0C );
        lcd_cmd ( 0x06 );
        lcd_cmd ( 0x80 );
        lcd_cmd ( 0x01 );
        delay_ms ( 500 );

     

    Check your circuit connections also, use a variable resistor with the contrast pin of the LCD to adjust the contrast and also use a resistance in series with 15 th or 16 th pin to adjust the backlight.

     

    Suggest you to leave the simulating software and try it on the real hardware, because one day you have to do the project in the hardware and then you will find that you were actually wasting your time with the simulating softwares.

    June 12, 2013 at 3:34 am #9950
    ANJUSHA
    Participant

    thank you sir.

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

RSS Recent Posts

  • How know if solder iron has good quality tip? August 18, 2022
  • How does a transistor works as a switch? August 18, 2022
  • Peltier control August 18, 2022
  • How to set USB port as RS-485 entrance? How to interpret Growatt solar inverter commands? August 18, 2022
  • Component Identification August 18, 2022

Stay Up To Date

Newsletter Signup
EngineersGarage

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