- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
But FPU will help to do internal multiplications i.e., within sqrt or sin/cos functions?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
"But FPU will help to do internal multiplications i.e., within sqrt or sin/cos functions?"
Yes, of course.
Bob