AnsweredAssumed Answered

Problem with local  variables when debugging with CW 4.5 and 9s12X

Question asked by DEREX Pascal on Apr 20, 2007
Latest reply on Apr 24, 2007 by CompilerGuru
Hello,
 
I have this function  :
BYTE GainToIndice(BYTE gain)
{
 BYTE i,g,ind;
 SBYTE diff;
 
 g=0xFF;
 for (i=0;i<BufConfig.nbgains;i++)
 {
   diff=BufConfig.gains[i].gain-gain;
   if (diff<0)
     diff=-diff;
   if(diff<g)
   {
     g=diff;
     ind=i;
   }
 }
}
 
I call it in my main program like GainToIndice(100)
 
When i debug it and look for example gain the value is 255. The value of i is always 52  whereas BufConfig.nbgains is 12, the value of g never changes (always 0). However the result is true.
I have tried a lot of -on optimisations but i didn't find the correct for my problem.
 
Thank you
 
Regards

Outcomes