This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ARM-CGT: Float operation on R4 or M4 core

Part Number: ARM-CGT
Other Parts Discussed in Thread: TMS570LS2124, TMS570LS1224

Hello All,

In previous follow up I was told to include the option --float_support=VFPv3D16 to have the compilation of Code on R4F, My complete options are 

'Invoking: ARM Compiler'
"E:/ti-cgt-arm_16.9.6.LTS/bin/armcl" -mv7R4 --code_state=16 --float_support=VFPv3D16 -me --include_path="E:/ti-cgt-arm_16.9.6.LTS/include" --include_path="E:/XXXX_R4" --define=PREPROC_SW_TEST_ENABLED -g --diag_warning=225 --diag_wrap=off --display_error_number --enum_type=packed --abi=eabi --preproc_with_compile --preproc_dependency="YYY/XXXXX.pp" --obj_directory="YYY" "../YYY/XXXX_R4.c"

Now I am facing problem in basic floating point operation like multiply\divide

for eg

uint64_t u40PowerInLinSum; 

float fRecipEnerLinSum,dRangeOffset, dVelocityOffset;

fRecipEnerLinSum = (float)((float)1.0 /(float)u40PowerInLinSum); //u40PowerInLinSum value is 1612388

dxxOffset = (float)si32xx * fRecipEnerLinSum; //si32xx -687948
dyyOffset = (float)si32yy * fRecipEnerLinSum; //si32yy 640046

Result of above operation is fRecipEnerLinSum is 0, dxxOffset and dyyOffset 0x20202020, I checked these result in watch and also in the memory as sometime the watch shows wrong result

All this result is resulting in junk results.

I saw during compilation I use --float_support=VFPv3D16 what is the meaning of this and will this enables the floating point operations or not?

Or I am doing something wrong

Br

Deepak Joshi

  • These computations combine very large and very small numbers.  The type float is a 32-bit representation, and the type double is a 64-bit representation.  Thus, double has more range and more precision than float.  Is it practical to change to type double?  Even just for these few computations?  

    Thanks and regards,

    -George

  • Hello George,

    I tried even double now the result changes to uninitialized garbage value for double, Some how for me the floating point operations are not happening. Can you please help me figuring out the reason for this?

    Br

    Deepak Joshi

  • Hello George,

    to explain this I am attaching a blank CCS project i made for R4(ForTI_R4.zip), Here it has all my compiling option and project option.

    In the main.c if you comment line No 88 and use the define you can see that f32EqShortCut is getting calculated correctly as there is all defines.

    The moment you have calculation then if you use either float and double the results are wrong.

    Br

    Deepak Joshi

    ForTI_R4.zip

  • Exactly which Cortex-R4 device do you use?  It may not support floating point instructions, in which case you should change to --float_support=none.

    Thanks and regards,

    -George

  • Hello George,

    I checked TMS570LS2124 - 16/32 Bit RISC Flash MCU, Arm, In the data sheet it's mentioned as 

    Which mentioned it has FPU unit but my operations are going wrong, Can you please help me in this regard

    Br

    Deepak Joshi

  • I no longer think I am the best person to handle this thread.  The data sheet for TMS570LS2124 says "The device supports the word-invariant big-endian [BE32] format."  But your CCS project uses the compiler switch -me, for little endian code.  Those two do not match.  But I may be overlooking something.

    I have notified the device experts about this thread. 

    Thanks and regards,

    -George

  • There were several issues with your project. First it was configured for a RM46L842 instead of a TMS570LS1224. Then it was missing all of the initialization files. I corrected these issues and ran the code on an XL2-TMS57012 launchpad. I have attached the modified project in a zip file. The values I got were:

    f32EqShortCut float 1.96798356e-41

    DETC_f32VelocityResolutionUmps double 0.22407472133636475

    4073.ForTI_R4.zip

  • Hello Bob,

    Is it possible for you to reattach the project with changed settings? i guess by mistake you attached the wrong project from me

    I was knowing i had some problem but couldn't find out what i need to do to work with floating point operation on the simulator.

    Br

    Deepak Joshi

  • I downloaded the project that I attached in the response above. That is your project with my modifications. Why do you think it is the wrong project?

  • Hello Bob,

    I run Beyond Compare on the folder I see there is only change in .cproject

    when i imported this to CCS i see following settings

    " -mv7R4 --code_state=16 --float_support=VFPv3D16 -me --include_path="E:/workspace_v5_5/ti-cgt-arm_16.9.6.LTS/include" --include_path="C:/Users/djoshi/Desktop/4073.ForTI_R4/ForTI_R4" --define=PREPROC_SW_TEST_ENABLED -g --float_operations_allowed=all --diag_warning=225 --diag_wrap=off --display_error_number --enum_type=packed --abi=eabi"

    also 

    when i launch in the simulator using R4.ccxml present in the folder I see again the same issue, I know there's some issue with my settings but unfortunately I am not able to PinPint this.

    I will be really obliged if you can help me in solving this.

    Thanks for yours help

    Br

    Deepak Joshi

  • What version of Code Composer Studio are you using? What hardware are you attached to? 

  • You mentioned a simulator. The very old ARM Cortex R4 simulator did not support the floating point hardware. The processor in the TMS570LS1224 is a Cortex R4F (the F means with floating point hardware). I suggest you purchase a XL2-TMS57012 launchpad and download the latest version of CCS for development work.

  • Hello Bob,

    I am using old ccs version 5.5, Is it possible can you point to the correct simulator for R4F, or if you know the version can you tell me this. I can ask our TI FAE to have this simulator version available to us . This is really helpful for us to try our porting first on simulator before we move to HW as simulator gives us the space to play.

    Thanks again for yours help.

    Br

    Deepak Joshi

  • TI does not have a simulator for R4F and no longer supports the simulator for R4 or CCS v5.5. I have moved other customers from using a simulator to using the XL2-TMS57012 launchpad. The launchpad  is a much better development tool than the simulator. It is cycle accurate, contains the floating point unit, the Memory Protection Unit and the peripherals.