Building Board Support Package (BSP) for STM32F411-Nucleo64 Part10: FPU Support

In this tenth part of Board Support Package, we shall enable the FPU (Floating Point Unit) inside the STM32F411 Nucleo-64 to improve the handling of floating point calculation in the firmware. (Needed later also).

In this guide, we shall cover the following:

  • Setting FPU within STM32CubeIDE.
  • Enabling the FPU in the firmware.

1. Setting FPU within STM32CubeIDE.

Open STM32CubeIDE and select the BSP project.

Then right click on the project and select properties as following:

Then new window will open.

Select C/C++ General then paths and symbols and select symbols as following:

Add the following:

FPU_EN

If you set the value to 1, it will enable the FPU, set it to 0 will disable the floating point unit.

After that, click on apply and close. It will ask to rebuild the project index, click yes.

Thats all for the STM32CubeIDE setup.

2. Enabling The FPU in out Firmware:

open the main.c of the project:

Add the following three lines of commands:

#if FPU_EN
	SCB->CPACR |= ((3UL << 10*2)|(3UL << 11*2));
#endif

This will provide full access to the FPU as mention in CortexM4 Generic guide:

Happy coding 🙂

Add Comment

Your email address will not be published. Required fields are marked *