Issue with R5 Processor's Casting from "Long" to "Double"

Dear community,
I am using a Xilinx ZCU106 with an ARM Cortex R5 cpu together with FreeRTOS.
I need your assistance regarding the casting issue from “long” to “double” in a C code application within the FREERTOS environment.

I have attached 3 pictures to illustrate the problem:

  1. ellipse0_ok.PNG: Correct calculation of the value “ellipse0,” resulting in 1695208.
  2. ellipse1_WrongCastingToDouble.PNG: Incorrect result of the value “ellipse1” (4.08714728854E-313) after casting from long to double.
  3. assemblyCodeEllipse0toEllipse1.PNG: Assembly code snippet for potential insights into the problem’s root cause.

The casting problem from double to long intermittently occurs, and I suspect it might be related to the processor itself. I’m wondering if there is any ERRATA or known issue concerning the processor’s casting to double. This problem is causing significant disruptions, and we are struggling to debug it effectively or identify the specific factors contributing to it.

Thank you for your response and support.
Best regards,

Which FreeRTOS port and version are you using? What is the value of configUSE_TASK_FPU_SUPPORT in your FreeRTOSConfig.h? Depending on the value, there are 2 possible options -

  1. If configUSE_TASK_FPU_SUPPORT is set to 1 - every task that uses floating point calculation needs to call portTASK_USES_FLOATING_POINT().
  2. If configUSE_TASK_FPU_SUPPORT is set to 2 - every task has a floating point context by default and no explicit action is needed.

Note that this support for setting configUSE_TASK_FPU_SUPPORT to 2 was added recently. If you are not using the latest FreeRTOS version, can you update and try setting configUSE_TASK_FPU_SUPPORT to 2?

NOTE - the above suggestion assumes that you are using this port.

1 Like

Hello Gaurav,
Thank you very much.
I’m testing this fix and it looks much better!
Thank you