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 / can not compile lcd code in keil

can not compile lcd code in keil

|

Projects › Projects › can not compile lcd code in keil

  • This topic has 5 replies, 4 voices, and was last updated 12 years, 3 months ago by Gopi.g.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • March 14, 2013 at 5:47 pm #2189
    Parth
    Participant

     

      #include<reg52.h>
    #include<intrins.h>
    #include<string.h>
    #define LCD P0
    #define DELAY _nop_();
    void integer_lcd(int);
    sbit m1=P2^2;
    sbit op=P2^3;
    sbit time=P2^0;
    void init_lcd(void);
    void cmd_lcd(unsigned char);
    void data_lcd(unsigned char*);
    unsigned int i,n;
    void delay_ms(int);
    void main()
    {
     init_lcd();
    m1=0;
    time=1;
    op=0;
    n=10;
    display_lcd(“Foot Step Based”);
    cmd_lcd(0xC0);
    display_lcd(“Street Light”);
    delay_ms(100);
    cmd_lcd(0x01);
    while(1)
    {
    cmd_lcd(0x80);
    display_lcd(“Foot Step Based”);
    cmd_lcd(0xC0);
    display_lcd(“Street Light”);
     
    if(m1=1)
    {
    cmd_lcd(0x01);
    cmd_lcd(0x80);
    display_lcd(“Stepped”);
     cmd_lcd(0xC0);
      display_lcd(“Light ON “);
    for(i=0;i<=n;i++)
    {  
    cmd_lcd(0xc0);
    display_lcd(“Time: 00:”);
    integer_lcd(i);
    op=1;
    delay_ms(250);
    }
       i=0;
    op=0;
    }
    if(time==0)
    {
       cmd_lcd(0x01);
    cmd_lcd(0x80);
    display_lcd(“Set Time”);
      cmd_lcd(0xC0);
      display_lcd(”              “);
       n=n+1;
       integer_lcd(n);
    }
    }
    } 
    void init_lcd(void)
    {
      cmd_lcd(0x28);
      cmd_lcd(0x28);
      cmd_lcd(0x28);
      cmd_lcd(0x0C);
      cmd_lcd(0x06);
      cmd_lcd(0x01);
    }
    void cmd_lcd(unsigned char var)
    {
      LCD = ((var& 0xF0) | 0x04);
      LCD = 0;
      LCD = ((var<< 4) | 0x04);
      LCD = 0;
      delay_ms(2);
    }
    void data_lcd(unsigned char var)
    {
      LCD = ((var& 0xF0) | 0x05);
      LCD = 0;
      LCD = ((var<< 4) | 0x05);
      LCD = 0;
      delay_ms(2);
    }  
    void display_lcd(char *str)
    {
      while(*str)
      data_lcd(*str++);
    }
    void delay_ms(intcnt)
    {
      int i;
      while(cnt–)
      for(i=0;i<500;i++);
    }
    void integer_lcd(int n)
    {
    unsigned char c[6];
    unsigned int i=0;
    if(n<0)
    {
    data_lcd(‘-‘);
    n=-n;
    }
    if(n==0)
    data_lcd(‘0’);
    while(n>0)
    {
    c[i++]=(n%10)+48;
    n/=10;
    }
    while(i–>=1)
    data_lcd(c);
    }
     
     
     
     
     
    pls help me
    March 15, 2013 at 1:57 pm #9321
    Savio
    Participant

    Hey Parth,

     

    It would be very helpfull if you could post your code with comments explaining the steps taken by you.

    I assume you are using LCD in 4-bit mode. If so, initialize the LCD in 4-bit mode with command 0x02.

    I have faced problems using KEIL while using ” #define LCD P0;”. Instead i’ve used “sfr P0=LCD;”.

     

    Hope you solve your problem,

    Regards.

    March 15, 2013 at 6:49 pm #9324
    AJISH ALFRED
    Participant

    Hi Parth,

    Please post your ‘error dialogue’ so that we can have a better idea about the issue.

    March 17, 2013 at 4:09 pm #9335
    Parth
    Participant

    i have one error and warning

    warning C206 :- ‘display_lcd’ missing function prototype

    erroe C267 :_ ‘display_lcd’ require ANSI-style prototype

    March 18, 2013 at 1:51 pm #9340
    Savio
    Participant

    Regarding warning, you are missing a few function prototypes. Mention all the funtions used in your program before the ‘main()’ funtion. i.e. ” void display_lcd(unsigned char *str);”

     

    Regarding error, this is a code which I usually use,

     

    void display_lcd(unsigned char *str)

    {

         while(*str!=0)

                 {   

                      data_lcd(*str);

                      str++;

                  }

    }

     

    Hope this helps, good Luck.

     

    March 19, 2013 at 5:00 am #9342
    Gopi.g
    Participant

    Hi,

     

    Parth,

     

    I think your program is correct. once check 10 k preset (most important for 2*16 lcd display).

     

    Thanks.

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

RSS Recent Posts

  • How to make string LEDs? July 11, 2025
  • PIC KIT 3 not able to program dsPIC July 11, 2025
  • Display TFT ST7789 (OshonSoft Basic). July 10, 2025
  • Remote Control By Location Part 2 July 10, 2025
  • Raise your hand if your car had one of these: July 10, 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