cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 6 MCU

Esteemed Contributor II

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

0 Likes
Reply
1 Solution
Employee

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

View solution in original post

0 Likes
Reply
5 Replies
Employee

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

View solution in original post

0 Likes
Reply
Anonymous
Not applicable

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?

0 Likes
Reply
Esteemed Contributor II

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

0 Likes
Reply
Anonymous
Not applicable

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

0 Likes
Reply
Esteemed Contributor II

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

Yes, of course.

Bob

0 Likes
Reply
Top labels