This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

floating point issue with softfp and nRF52840

I am trying to get a driver from a third party binary to work.  Their library was compiled without using the HW FPU.  I had to compile my code to use the softfp.  I also added the _printf_float option.  I am running on a RF52840, GCC, Eclipse, Windows, on a custom board.  There seems to be issues with basic floating point commands.  Here is an example:

This doesn't work but it should:
      printf("%u\t%u", (unsigned int)index, (unsigned int)(power_bins_data[index] + 0.5));
This doesn't work but it should:
    tempInt = (unsigned int)  (power_bins_data[i] + 0.5);     //fails executing this command, power_bins_data[i] is a float  
    printf("%u\t%u",i, tempInt);
This works:
   tempFloat = power_bins_data[i] + 0.5;
   tempInt = (unsigned int) (tempFloat);
   printf("%u\t%u",i, tempInt);
I have never had issues with floating point before with the nRF52 or nRF51 but I always used the HW FPU.  
Steve
Parents Reply Children
  • Any casting doing floating point math will cause the crash.  The problem has do to with the software floating point unit.   Either something wrong with how I used it or the softfpu itself.  I was able to get the other vendor to compile their library with the hardware FPU on.  I recompiled with HW FPU and it solved the problem.  I have never had an issue using the HW FPU.

Related