Keil Logo

ARMCC: How to enable the hardware FPU support for Cortex-M7


Information in this knowledgebase article applies to:

  • ARMCC compiler v5.05 or higher
  • MDK-ARM v5.00 or higher

QUESTION

I know that Cortex-M7 has the option to support a hardware Floating Point Unit (FPU). For instance, I'm using the device Atmel ATSAMV71 that has the hardware FPU support for double floating-point operations. How can I enable this hardware FPU support in my project?

ANSWER

For this specific device Atmel ATSAMV71, after installing the corresponding device support pack *_DFP and CMSIS pack, there is a CMSIS-RTOS Blinky example that can be installed via MDK-ARM Pack Installer, which can be used as a reference to see how to change different FPU support options.

In this CMSIS-RTOS Blinky example, open Options for Target - Target - Floating Point Hardware, as shown in this screenshot:

Floating Point Hardware Options

There is a drop-down list to select from these three options:

  • Not Used
  • Use Single Precision
  • Use Double Precision

After selecting this "Floating Point Hardware" option, µVision will set up the corresponding C/C++ option and linker option in Options for Target - C/C++ - Compiler control string and Options for Target - Linker - Linker control string accordingly, as explained as follows:

  • by selecting "Not Used", --cpu=Cortex-M7 to compiler and linker option is added: for this --cpu option, the option --cpu=Cortex-M7 --fpu=SoftVFP is implicitly defined, which means only software floating-point support is selected where floating-point operations are performed by a floating-point library, fplib.
  • by selecting "Use Single Precision", --cpu=Cortex-M7.fp.sp to compiler and linker option is added: for this --cpu option, the option --fpu=FPv5-SP is implicitly defined, which means hardware floating-point unit is selected conforming to the single precision variant of the FPv5 architecture.
  • by selecting "Use Double Precision", --cpu=Cortex-M7.fp.dp to compiler and linker option is added: for this --cpu option, the option --fpu=FPv5-DP is implicitly defined, which means hardware floating-point unit is selected conforming to the double precision variant of the FPv5 architecture.

Moreover, in the SystemInit() routine for the CMSIS library, the following codes are specified accordingly to the SystemInit() function of your system startup C file, in order to enable the FPU.

#if (__FPU_USED == 1)                   // Keil
  /* enable FPU if available and used */
  SCB->CPACR |= ((3UL << 10*2) |             /* set CP10 Full Access               */
                 (3UL << 11*2)  );           /* set CP11 Full Access               */
#endif

Although for Contex-M7 Floating-Point Extension (FPv5) is recommended for both single and double precision operations because of its additional floating point processing instructions which might help speed up the floating point data processing in your application, you can still specify different Floating-Point Extension, such as FPv4 for the single precision operations. In order to do so, you can specify --fpu=FPv4-SP option, such as --cpu Cortex-M7.fp.sp --fpu=FPv4-SP which overrides any implicit FPU option that is defined by --cpu=name option.

If you have a Cortex-M7 device that is not yet supported by any MDK Device Family Pack, you can take this example as a reference to set up the compiler and linker options and the SystemInit() routine accordingly to enable the hardware FPU support.

MORE INFORMATION

SEE ALSO

FORUM THREADS

The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Wednesday, January 25, 2017


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.