5 Replies Latest reply on Nov 7, 2017 3:55 AM by user_1377889

    How to enable / disable the M4 floating-point unit

    user_1377889

      The M4 internal floating-point unit is disabled by default after startup of the CPU. Are ther any Cy-system calls to enable or disable the FPU?

       

      Bob

        • 1. Re: How to enable / disable the M4 floating-point unit
          msur

          Bob,

           

          PSoC Creator enables the floating point unit automatically, if you enable floating point code compilation (compiler command line input). And by default PSoC Creator enables the floating point code compilation to compiler parameters for M4. You can check that in "Project > Build settings > CM4 > Compiler" and then looking at the compiler parameters generated in grey box on the bottom right side pane. The below line instructs the compiler to compile the code for a device with FPU (the one available in M4). softfp parameter uses normal CPU registers(Rx) for floating point argument passing to a function, where as hardfp use floating point registers(Sx) for floating point argument passing. softfp typically compiles with most floating point libraries (already compiled and linked libraries - like sin/cos libraries). hardfp require hardfp libraries for proper compilation.

           

          "-mfloat-abi=softfp -mfpu=fpv4-sp-d16" - for GCC

           

          The floating point enable code is available in "system_psoc63_cm4.c" file - Cy_SystemInitFpuEnable() function. Note that this function will only enable FPU if compiler is instructed to generate floating point code as mentioned above and is automatically called from the CM4 startup code. You can refer to the function implementation for enabling /disabling the FPU in you application.

           

          Let me know if this helps.

           

          Regards,

          Meenakshi Sundaram R

          • 2. Re: How to enable / disable the M4 floating-point unit
            muhammad.yaqoob_1490236

            Sir,

             

            Long story short,

            You meant to say that, we just have to start doing floating point calculation in main_cm4.c e.g., sqrt, sin, cos etc? And It will automatically assign to FPU?

            • 3. Re: How to enable / disable the M4 floating-point unit
              user_1377889

              Not quite.

              The ARM M4 has got an FPU (Floating Point Unit) which speeds up any floating point operations as add, multiply and divide using a set of special registers. This feature seems to be enabled by default. Sqrt, sin, cos etc are library functions and there is a special library for M4 taken automatically to increase performance.

               

              Bob

              • 4. Re: How to enable / disable the M4 floating-point unit
                muhammad.yaqoob_1490236

                But FPU will help to do internal multiplications i.e., within sqrt or sin/cos functions?

                • 5. Re: How to enable / disable the M4 floating-point unit
                  user_1377889

                  "But FPU will help to do internal multiplications i.e., within sqrt or sin/cos functions?"

                  Yes, of course.

                   

                  Bob