cancel
Showing results for 
Search instead for 
Did you mean: 

I would like to turn the FPU in the STM32L486 completely off and want to be sure that the compiler is not generating ANY floating point instructions. Is the FPU completely off if I leave the CPACR alone after reset? Is there a flag I can pass to gcc?

User1655833706281357277
Associate III
 
3 REPLIES 3
TDK
Guru

The floating point implementation for the compiler to use is passed as an argument. Passing -mfloat-abi=soft will prevent it from generating hardware FPU instructions. This is done within project settings in STM32CubeIDE.

Leaving CPACR alone will keep the FPU off. Enabling it is done within SystemInit if you have the appropriate defines enabled.

  /* FPU settings ------------------------------------------------------------*/
  #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
    SCB->CPACR |= ((3UL << (10*2))|(3UL << (11*2)));  /* set CP10 and CP11 Full Access */
  #endif
  /* Reset the RCC clock configuration to the default reset state ------------*/

If you feel a post has answered your question, please click "Accept as Solution".
User1655833706281357277
Associate III

Just curious, is there any gcc option to completely prevent any floating point code generation at all -- maybe throw an error or warning? It looks like some ARM architectures support a -march=<blah>+nofp to do that.

Thank you,

--b