Need Assistacne---------- LCD Display coding in 8051C

Discussion in 'Programmer's Corner' started by triplehdineshbabu, Feb 18, 2009.

Thread Status:
Not open for further replies.
  1. triplehdineshbabu

    Thread Starter Active Member

    Feb 5, 2009
    38
    0
    Hi all,

    I have written the LCD Display coding in 8051C, Kindly Check and tell me whats error in this program

    ---------_------

    #include<reg52.h>
    #include<intrins.h>
    sbit rs=P3^5;
    sbit rw=P3^6;
    sbit en=P3^7;
    sbit busy=P1^7;
    unsigned char *L1="Dinesh";
    unsigned char *L2="Babu";
    void lcd_inz(void);
    void address_write(unsigned char);
    void data_write(unsigned char);
    void delay(unsigned int);
    void string_write(char*);
    void check();
    void main()
    {
    lcd_inz();
    delay(10);
    while(1)
    {
    address_write(0x80);
    string_write(L1);
    delay(10);
    address_write(0xc0);
    string_write(L2);
    delay(10);
    }
    }
    void delay(unsigned int i)
    {
    int k;
    for(k=0;k<i;k++)
    {
    _nop_();
    }
    }
    void lcd_inz()
    {
    address_write(0x01);
    address_write(0xc0);
    address_write(0xc0);
    address_write(0x80);
    address_write(0x38);
    address_write(0xe0);
    }
    void address_write(unsigned char x)
    {
    P1=x;
    rs=0;
    rw=0;
    en=1;
    delay(10);
    en=0;
    check();
    }
    void check()
    {
    busy=1;
    en=1;
    rs=0;
    rw=1;
    while(busy==1)
    {
    en=0;
    delay(10);
    en=1;
    }
    }
    void string_write(unsigned char *v)
    {
    while(*v!='\0');
    {
    data_write(*v);
    v++;
    }
    }
    void data_write(unsigned char y)
    {
    P1=y;
    rs=1;
    rw=0;
    en=1;
    delay(10);
    en=0;
    check();
    }



    ------------------

    thanks In advance

    Regards,

    Dinesh
     
Loading...
Thread Status:
Not open for further replies.