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
  • I think something got lost, so here we go
    where you in the below see [ use <
    where you in the below see ] use >
    kapil,

    Please repost those message with formatting intact. Put a tag [pre]
    BEFORE copying in your source, and then put [/pre] after it. Thanks. It's almost completely unreadable as it is.

Reply
  • I think something got lost, so here we go
    where you in the below see [ use <
    where you in the below see ] use >
    kapil,

    Please repost those message with formatting intact. Put a tag [pre]
    BEFORE copying in your source, and then put [/pre] after it. Thanks. It's almost completely unreadable as it is.

Children
  • Hehehe... That's what I get for not hitting preview first.

  • When you make a post, immediately above the 'Message:' box where you type are some 'Notes' which explain how to post code.

    A link is also given for "Tips for Posting Messages" which gives further details & examples.
    The link is: http://www.keil.com/forum/tips.asp

  • I am sorry Jay, Erik, A.W for a bad Posting

    Anyways i was abnle to locate the problem

    I am using 7135 ADC which outputs the data in nibbles( 5 nibbles for one conversion)

    Each nibble nibble when ready, signals a STROBE, which is recived as interrupt signal in the microcontroller.

    The 5th nibble when ready generates another signal D5 along with STROBE signal.

    SO in interrupt we need to check the status of D5 pin so as to syncronize the data

    The ISR used is following

    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;

    }

    i have used a array Nibble[4] to collect the data and nibble_reference, a variable which guides the nibble to be placed at their right position.

    Now if their are supurious interrupts, generated because of any reason, then their is a big problem

    Because between 2 high signals of D5 we will recive more than 5 interrupts that means more than 5 times the increment of nibble_reference

    Which means we have gone outside the array Nibble[4] and destroying the next variable in line

    now the variables listing is like

    D:0x23 Nibble array[5]uchar
    D:0x28 nibble_reference uchar
    D:0x29 Present_Value uint
    D:0x2B STAGE_1_CNT uint
    D:0x2D STAGE_2_CNT uint
    D:0x23 ........... ........uint

    It is very clear the if D5 pulse is missed, it will destroy the nibble_reference variable and the more variavle in line.

    So STAGE_1_CNT and STAGE_2_CNT seems to be vunerable in the present senirio

    so finally it is a hardware problem but the software could be more robust which i will try to make.

    Anyways Thanks to all of you for you help.

    Thanks and Regards,
    Kapil