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

debuger show inadequate values

#include <string.h>
#include <stdio.h>
#include <LPC214x.H>


volatile int rc=0;
volatile float A0 = 15.2, B0 = 0.152;
int tst(const int iprivod,int id0, float iV0)
{  int iS0, iS2, it0, idx1, idt, iS_m=0x1234, it_m;
   iS_m = (int)(A0 * A0 /B0);
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//Locals window show here 0x40000468 for iS_m
//and 0x000005F0 if next line is commented

   iS_m = A0 * A0 ;
   it_m = A0/B0+0.5;
   id0 = iS_m;
   if(iV0 < 0.)
   {
      it0 = iV0/B0+0.5;
   } else {
     iS0 = iV0*iV0/(B0*2.);
   }
   if(id0 <= iS0)
   {     if(iprivod > 0)
                 {
            idx1 = 123;
                 } else idt = 321;//it_m;
         return 0;
   }

   iS2 = (id0 + iS0);

   if(0x1235 > iS_m)
   {
return iS_m;
   }
return 2;

}

int main (void)
{
  while(1)
  {
  rc=  tst(1,1520, 0.);
  }
}

Parents
  • "what is wrong with code with float point operatons that work fine from main() and work fine from interrupt routine in debuger, but hang up in real processor."

    Do you mean debugger, or Simulator?

    If it works in the Simulator, but not the real target (which is opposite to the other thread that you cited), that suggests that you have some hardware interaction that causes the problem.

    This could be a bug or fault in your hardware, or could be something perfectly normal that your software doesn't handle correctly - eg, another interrupt occuring - which you haven't (properly) accounted for in your simulation.

    Unless your processor has hardware floating point support, remember that all floating point operations will include Library calls - are you sure that your FP library is safe for use from interrupts?
    eg, is it reentrant? is it safe from atomicity issues?

Reply
  • "what is wrong with code with float point operatons that work fine from main() and work fine from interrupt routine in debuger, but hang up in real processor."

    Do you mean debugger, or Simulator?

    If it works in the Simulator, but not the real target (which is opposite to the other thread that you cited), that suggests that you have some hardware interaction that causes the problem.

    This could be a bug or fault in your hardware, or could be something perfectly normal that your software doesn't handle correctly - eg, another interrupt occuring - which you haven't (properly) accounted for in your simulation.

    Unless your processor has hardware floating point support, remember that all floating point operations will include Library calls - are you sure that your FP library is safe for use from interrupts?
    eg, is it reentrant? is it safe from atomicity issues?

Children