Floating Point Multiplication Issue with Xilinx_Freertos

amaramar wrote on Monday, October 14, 2019:

Hi,
I am using xilinx freertos on zynq platform. I got stuck as i found that the floating point multiplication doen not work properly; code is as below,
int gloabal_data1=-1;
float global_data2=1.5;

vTask_Mul()
{
int mul_res;
while(1)
{
mul_res=(int)(gloabal_data1*gloabal_data2 * 10);
printf("%d",mul_res);
}
}

mul_res gives some crazy numbers like -32000.
Could anyone suggest what could be the issue?
RTOS Config as follows:
configUSE_TASK_FPU_SUPPORT 2

Thank you .

rtel wrote on Monday, October 14, 2019:

Can you please validate that the code you posted works as you expect
outside of the kernel. To do that you can just try calling it before
you call vTaskStartScheduler(). If it works before the scheduler has
started but not after then we can try and figure out why (could be stack
alignment, etc.).

amaramar wrote on Tuesday, October 15, 2019:

Thank you.
I figured out, Nothning wrong with RTOS. Silly error with type casting on 32 bit processor.