lpcware

math.h on 43xx

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by ArriaLive on Sat Nov 08 17:05:17 MST 2014
I'm trying to use some fairly basic math.h functions (including sinf() and cosf()) in a project that is running on an LPC4330.  I am using the FPv4-SP (Soft ABI) floating point library as recommended by these forums.  I can work with float numbers--add, subtract, multiply, divide, etc., but when I add the math.h functions (even in single-precision floating-point mode), I get a hardfault with a NoCP (no coprocessor) fault.

Here's my test code:

/* This one works */
float testfunction(void) {
  float a,b;
  a = 2.5F;
  b = 2.0F*a;
  return b;
}

/* This one gets a hard fault (NoCP) */
float testfunction(void) {
  float a,b;
  a = 2.5F;
  b =sinf(a);
  return b;
}

Any ideas what I'm doing wrong?  Am I missing a parameter somewhere?

Thanks,

Outcomes