This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

p89v51rd2 code simukation working but after burning not working

I am using following program for P89v51rd2. In Keil simulation is working but when i am burning same using Flash Magic ,it is not working. I have checked Memory Data using Flash Magic It is same as in Keil Debugger.Nothing is working after burning ,no port data updation is taking place. Please help Me.

//Program for RFID based Secured access system using 8051 microcontroller
#include <intrins.h>
#include <p89v51rx2.h>
sfr lcd_data_pin=0xA0;  //P2 port
sbit rs=P1^0;
sbit rw=P1^1;
sbit en=P1^2;


void delay(unsigned int count)  //Function to provide time delay
{
        int i,j;
        for(i=0;i<count;i++)
        for(j=0;j<1275;j++);
}

void lcd_command(unsigned char comm)   //Lcd command funtion
{
        lcd_data_pin=comm;
        en=1;
        rs=0;
        rw=0;
        delay(1);
        en=0;
}

void lcd_data(unsigned char disp)  //Lcd data function
{
        lcd_data_pin=disp;
        en=1;
        rs=1;
        rw=0;
        delay(1);
        en=0;
}

lcd_string(unsigned char *disp)  //Lcd string function
{
        int x;
        for(x=0;disp[x]!=0;x++)
        {
                lcd_data(disp[x]);
        }
}

void lcd_ini()                            //Function to initialize the LCD
{
        lcd_command(0x38);
        delay(5);
        lcd_command(0x0F);
        delay(5);
        lcd_command(0x80);
        delay(5);
}


void main()
{
                                                                // Trigger Timer 1
        lcd_ini();
        lcd_command(0x80);                                      //Place cursor to second position of first line
        lcd_string("Pls scan your ID");
        delay(200);

}


Regards
Manish

  • In Keil simulation is working but when i am burning same using Flash Magic ,it is not working.

    why does that surprise you?

    void delay(unsigned int count)  //Function to provide time delay
    {
            int i,j;
            for(i=0;i<count;i++)
            for(j=0;j<1275;j++);
    }
    


    this is ridiculous in 'C', where does '1275' come freom.

    did you believe that the simulator checked for sufficient delays?

    Erik

  • sir,

    I've tried to compile the program that you have posted but its giving some error like "LCD.C(9): warning C206: 'lcd_command': missing function-prototype
    LCD.C(9): error C267: 'lcd_command': requires ANSI-style prototype"

    plz explain whatz the problem... i think there must be a library file for lcd...what is the procedure to add that?

  • Dear paramasivam ; Thanks for trying my program...this is error due to declaration of function...whenever you specify function before "Main" it is know as function prototype decleration...so please insure you have declear rightly before "main", for more details please refer any "c language" book.secondly i did mistake by setting LCD brightness too high that is why it was appearing as not working.

    Regards
    Manish Puraswani

  • i found bug and fix it for you

    void delay(unsigned int count)  //Function to provide time delay
    {
        unsigned int i,j;
        for(i=0;i<count;i=i+1)
            for(j=0;j<1395;j=i+1)
                ;
    }
    

  • dear mr. saralam
    thanks for providing solution, but sorry to say you ,it will not work as 1)it will create infinite loop as j is not going to increase 2) i=i+1 is same as i++ (please refer special operator in c)