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

troubles debugging C-code

Hi all,

In combination with my STR710 microcontroller I am using:

IDE-Version:
µVision3 V3.23

With the tools:

Tool Version Numbers:
Toolchain Path: C:\Keil\ARM\BIN\
C Compiler: CA.Exe V2.42
Assembler: AA.Exe V2.40b
Linker/Locator: LA.Exe V2.42
Librarian: LIBA.Exe V4.26
Hex Converter: OHA.Exe V2.10
CPU DLL: SARM.DLL V1.29
Dialog DLL: DARMST.DLL V1.03
Target DLL: BIN\UL2ARM.DLL V1.14a
Dialog DLL: TARMST.DLL V1.03

I have troubles debugging C-code.
If I use global or local variables and I initiate these global/local variables at the begin of a program or function I can not set breakpoints at these text lines in debugging mode. And during debugging these textlines are ignored/not executed.

In the example below in debugging mode uVision does not set the grey blocks before text lines 0952, 0953 and 0955. And it does set a grey block at line 0954 and all the other code.

void ADC12_IRQHandler(void) __irq
{

/*line 0952:*/ short ADCsample_MAX_temp = 0;
/*line 0953:*/ short ADCsample_MIN_temp = 0;
/*line0954:*/ short ADCsample_MAV_Filter = 0;
/*line 0955:*/ int i;

ADCsample_MAX_temp = ADCsample_MAX_temp + (ADCsample+30); //zet bandfilter op +30 t.o.v laatste sample
ADCsample_MIN_temp = ADCsample_MIN_temp - (ADCsample-60); //zet bandfilter op -30 t.o.v laatste sample

for(i=0; i>=8; i++)
{

if((ADC_DATA0 & 0x8000)!=0)/************************Roer staat links*******************************/
{
ADCsample = ADC_DATA0;
ADCsample = ADCsample >> 5;
ADCsample = ~ADCsample;
ADCsample &= 0x000007FF;
ADCsample |= 0x0400;
}

if((ADC_DATA0 & 0x8000)==0)/*************************Roer staat rechts*****************************/
{
ADCsample = ADC_DATA0; //
ADCsample = ADCsample >> 5; //5 LSB weg shiften, resultaat is 11 bits nauwkeurigheid
ADCsample = ~ADCsample;
ADCsample &= 0x000007FF;
ADCsample &= 0x3FF;
}

ADCsample_MAV_Filter += ADCsample;
}

ADCsample_MAV_Filter = ADCsample_MAV_Filter >> 3;

if((ADCsample_MAV_Filter >> ADCsample_MAX_temp) || (ADCsample_MAV_Filter << ADCsample_MIN_temp))
{
//storing, ADC waarde te hoog of te laag
}
else
{
ADCsample_MAV_Filter = ADCsample;
}

ADC12->CSR &= ~ADC12_DA0; /*clear sample ready flag*/
EIC->IPR = 1 << ADC_IRQChannel;

}


Does someone have an explanation for this?

Regards,

Erik

  • Too much optimazation?

    Tried your example and it works. (Grey blocks appear in front of the local variable initiation; in other words, I'm able to debug the initialization)

  • Erik,

    Depending on the optimization level -
    OT(7) or OT(8), the DEFinition in line 952 is detected as dead since it is followed by another DEFinition in line 957 with no intervening USE of the DEF in line 952 due to the second rule below. In this case, the compiler can remove the code of the dead DEFinition, and you can't set a breakpoint on line 952 anymore.

    If there are uses between 2 DEFinitions, the compiler may still remove them due to constant tracking, that is, recognizing the
    value of a variable and replacing the references by the known constant value. This case is true for line 957.

    You can avoid this by reducing the optimization level. Also, declaring the
    variables as 'volatile' will prevent them from being optimized.

    volatile unsigned int ADCsample;
    
    void ADC12_IRQHandler(void) __irq  {
    
    /*line 0952:*/ short ADCsample_MAX_temp = 0;
    /*line 0953:*/ short ADCsample_MIN_temp = 0;
    /*line0954:*/ short ADCsample_MAV_Filter = 0;
    /*line 0955:*/ int i;
    
    /*957:*/  ADCsample_MAX_temp = ADCsample_MAX_temp + (ADCsample+30);
      ADCsample_MIN_temp = ADCsample_MIN_temp - (ADCsample-60);
    }
    

    Hope that helps to understand what's going on here.

    Regards,
    Peter