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

Floating point exception on nrf9160

Hi,

 I have a problem with floating point types on nrf9160.

I get an exception when I get to a simple floating point assinment:

 void f(int i)

{

     float x;

     x = (float)i;

}

The disasemmbly is: vldr s15, r0

here is my prj.conf

CONFIG_PRINTK=y
CONFIG_HEAP_MEM_POOL_SIZE=256
CONFIG_ASSERT=y
CONFIG_GPIO=y
CONFIG_ADC_NRFX_SAADC=y
CONFIG_ADC=y
CONFIG_SERIAL=y
CONFIG_STDOUT_CONSOLE=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_ADC_ASYNC=y
CONFIG_TRACING=y
CONFIG_SEGGER_SYSTEMVIEW=y
CONFIG_SPI=y
CONFIG_CMSIS_DSP=y
CONFIG_NEWLIB_LIBC=y
CONFIG_FPU=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
CONFIG_CMSIS_DSP_BASICMATH=y
CONFIG_CMSIS_DSP_TRANSFORM=y
CONFIG_CMSIS_DSP_STATISTICS=y
CONFIG_CMSIS_DSP_COMPLEXMATH=y
CONFIG_CMSIS_DSP_SUPPORT=y

I've also added 

CONFIG_FLOAT=y

but it did not help.

Would you please help?

Thanks

Danny

Parents
  • Additional information:

    If I disable the compiler optimizations in prj.conf by

    CONFIG_NO_OPTIMIZATIONS=y

    It stops happening.

    But I need the optimizations.

    Does any one knows why GCC optimizations causes exceptions?

    Thanks

    Danny

  • Hi Danny,

    Are you doing float operations from multiple threads by any chance? The help text for CONFIG_FPU says that:

    "When this option is enabled, by default, threads may use the floating point registers only in an exclusive manner, and this usually means that only one thread may perform floating point operations.

    If it is necessary for multiple threads to perform concurrent floating point operations, the “FPU register sharing” option must be enabled to preserve the floating point registers across context switches."

    Please try to build with CONFIG_FPU_SHARING=y and see if it makes any difference.

    Best regards,

    Vidar

Reply
  • Hi Danny,

    Are you doing float operations from multiple threads by any chance? The help text for CONFIG_FPU says that:

    "When this option is enabled, by default, threads may use the floating point registers only in an exclusive manner, and this usually means that only one thread may perform floating point operations.

    If it is necessary for multiple threads to perform concurrent floating point operations, the “FPU register sharing” option must be enabled to preserve the floating point registers across context switches."

    Please try to build with CONFIG_FPU_SHARING=y and see if it makes any difference.

    Best regards,

    Vidar

Children
Related