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

Variable corruption

Hello,

I have developed an application using the 8051 and c51, there is a external memory 93c46 which contains the control variables for the applcations, these variables are read at the start of the application and are used further in the application.

The values read from the memory are stored in the global variables and are used in the different routiens for the control purpose

These variable get corrupted in the middle of the application causing unpridictable results.

How can i say these variable get Corrupted?

There is a ruotien to update these variables. The value of variables are displayed on screen and can be changed, after all the values are scaned and the values are stored back in the memory and application runs with the updated variables.

so if a variable gets corupted it is visible in the routien which updates these variables

More over if we switch off the application after seeing the corrupted variables in the the updation routien, before saving the corrupted variables, then after switching on the variables are read from the external memory perfectely well and can be seen quite well in the updation routien

I am using AT89c51 micro

which means the global variables get corrupted, which gets displayed in the updation rouotien

Any help will be highly appericiated

Thanks in advance
Kapil

Parents
  • This is interrupt file

    /* ADC.C */
    #include <reg51.h>

    #define HIGH 1
    #define LOW 0

    #define ON 1
    #define OFF 0

    extern unsigned char Nibble[5];
    extern unsigned char nibble_reference;


    sbit Mode_sw = 0xB7;
    sbit Down_sw = 0xB7;
    sbit Up_sw = 0xB6;
    sbit STOP_sw = 0xB6;
    sbit D5 = 0x94;
    sfr In_Data = 0x90;

    extern unsigned int COUNTER;
    unsigned char Temp_Counter=0;
    unsigned char Temp_Counter1=0;

    extern bit STOP_SW_bit ;
    extern bit Screen_Flag ;

    void Enable_Interrupts(){

    // Enable the Timer/Counter 0 Interrupt No 1
    TR0 = 0;
    TMOD &= ~0x0F; /* clear timer 0 mode bits */
    TMOD |= 0x01; /* put timer 0 into 16-bit no prescale */
    TL0 = 00;
    TH0 = 200;
    PT0 = 0; /* set low priority for timer 0 */
    ET0 = 1; /* enable timer 0 interrupt */
    TR0 = 1; /* start timer 0 */

    // Enable the Timer/Counter 1 Interrupt No 4

    // Enable the External 0 Interrupt No 0

    // Enable the External 1 Interrupt No 2
    EX1 = 1;
    // Enable the SCI Interrupt No 5

    // Enable Global
    EA = 1;
    }


    External_1() interrupt 2 using 3
    {
    if(D5)
    nibble_reference = 0; // this is the starting, MSB is sent after this

    Nibble[nibble_reference] = In_Data;
    Nibble[nibble_reference] &= 0x0F;
    ++nibble_reference;

    }


    Timer0 () interrupt 1 using 2
    {
    TL0 = 55;
    TH0 = 248;
    Temp_Counter++;

    if(Temp_Counter >= 100){
    Temp_Counter =0;
    Temp_Counter1++;
    COUNTER++; }


    }

Reply
  • This is interrupt file

    /* ADC.C */
    #include <reg51.h>

    #define HIGH 1
    #define LOW 0

    #define ON 1
    #define OFF 0

    extern unsigned char Nibble[5];
    extern unsigned char nibble_reference;


    sbit Mode_sw = 0xB7;
    sbit Down_sw = 0xB7;
    sbit Up_sw = 0xB6;
    sbit STOP_sw = 0xB6;
    sbit D5 = 0x94;
    sfr In_Data = 0x90;

    extern unsigned int COUNTER;
    unsigned char Temp_Counter=0;
    unsigned char Temp_Counter1=0;

    extern bit STOP_SW_bit ;
    extern bit Screen_Flag ;

    void Enable_Interrupts(){

    // Enable the Timer/Counter 0 Interrupt No 1
    TR0 = 0;
    TMOD &= ~0x0F; /* clear timer 0 mode bits */
    TMOD |= 0x01; /* put timer 0 into 16-bit no prescale */
    TL0 = 00;
    TH0 = 200;
    PT0 = 0; /* set low priority for timer 0 */
    ET0 = 1; /* enable timer 0 interrupt */
    TR0 = 1; /* start timer 0 */

    // Enable the Timer/Counter 1 Interrupt No 4

    // Enable the External 0 Interrupt No 0

    // Enable the External 1 Interrupt No 2
    EX1 = 1;
    // Enable the SCI Interrupt No 5

    // Enable Global
    EA = 1;
    }


    External_1() interrupt 2 using 3
    {
    if(D5)
    nibble_reference = 0; // this is the starting, MSB is sent after this

    Nibble[nibble_reference] = In_Data;
    Nibble[nibble_reference] &= 0x0F;
    ++nibble_reference;

    }


    Timer0 () interrupt 1 using 2
    {
    TL0 = 55;
    TH0 = 248;
    Temp_Counter++;

    if(Temp_Counter >= 100){
    Temp_Counter =0;
    Temp_Counter1++;
    COUNTER++; }


    }

Children
No data