1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

I'm writing a program for AT89C2051 but it's not working

Discussion in 'C, C++, C#' started by Confefe, Jun 1, 2017.

  1. Confefe

    Confefe Newbie

    Joined:
    Jun 1, 2017
    Messages:
    1
    Likes Received:
    0
    Gender:
    Female
    I have write a program in C language for AT89C2051 & load the Hex file in the Chip 89C2051 but it's not working. But when I same program write for AT89C51 the it is work properly.

    One more thing I was done. The same output code write in assembly & hex file load in the AT89C2051 then its work properly. My C code as Below:

    Code:
    #include<reg2051.h>           // special function register declarations
    
    sbit LED = P3^5;            // Defining LED pin
    sbit Relay = P3^7;
    sbit Music = P1^0;
    sbit Det  = P3^2;
    void Delay(void);           // Function prototype declaration
    void main (void)
    {
    
                         // infinite loop
        while (1)   
             {
             if (Det!=1)
                {
                Relay =0;
                LED = 0;            // LED ON
                Music = 0;
                Delay();
                LED = 1;            // LED OFF
                Music = 1;
                Delay();
                }
            else
                {
                 Relay =1;
                }
             }
    
                }
    
    void Delay(void)
    {
        int j;
        int i;
        for(i=0;i<10;i++)
        {
            for(j=0;j<10000;j++)
            {
            }
        }
    }
    So could you please tell me how solve this problem?