cancel
Showing results for 
Search instead for 
Did you mean: 

FPU is not initialized

richi
Associate III

/**
******************************************************************************
* @file : main.c
* @author : Auto-generated by STM32CubeIDE
* @brief : Main program body
******************************************************************************
* @attention
*
* Copyright (c) 2023 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/

#include <stdint.h>
#include <stdio.h>

#if !defined(__SOFT_FP__) && defined(__ARM_FP)
#warning "FPU is not initialized, but the project is compiling for an FPU. Please initialize the FPU before use."
#endif

int main(void)
{
printf("Hello world");

return 0;
}

// // //

Why does this warning show up every time I create a project. Is it something important, how do I get rid of it if I need to. I checked the settings and I initialized the FPU in properties.

richi_0-1702809778757.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
AScha.3
Principal III

what did you set in the code generator in cube ?

your "main" looks totally wrong - not generated for a cube/HAL stm32 project. 

should look like mine here:

AScha3_0-1702814215589.png

so try: make new stm32 project, maybe for F407 - disco board (i suppose, you have this, as i do), change nothing, just generate code. then look, what it looks like...and only write your code between "user code begin...// ...end " comments.

+ printf ... you know, where it should print to?    better just toggle a LED as a first test. not print...to nowhere.

+

read first :

https://www.st.com/resource/en/user_manual/um2609-stm32cubeide-user-guide-stmicroelectronics.pdf

 

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

View solution in original post

4 REPLIES 4
AScha.3
Principal III

what did you set in the code generator in cube ?

your "main" looks totally wrong - not generated for a cube/HAL stm32 project. 

should look like mine here:

AScha3_0-1702814215589.png

so try: make new stm32 project, maybe for F407 - disco board (i suppose, you have this, as i do), change nothing, just generate code. then look, what it looks like...and only write your code between "user code begin...// ...end " comments.

+ printf ... you know, where it should print to?    better just toggle a LED as a first test. not print...to nowhere.

+

read first :

https://www.st.com/resource/en/user_manual/um2609-stm32cubeide-user-guide-stmicroelectronics.pdf

 

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

How many times it must be told repeatedly to not post a code as an image? Here is a list of damage done by doing so:

  • Search engines cannot index.
  • Forum search engine cannot search.
  • Browser cannot search with Ctrl+F.
  • Increases the page load time.
  • Visually pollutes the forum.

Also the written text is meant to be read by others. Therefore at least the most basic things like capital letters and sentences should be used reasonably. By writing hardly readable flow of words, you are disrespecting the time and effort required by other people.

Code to enable should be in SystemInit(), that way main() won't fault if you have float or double auto variables in there. Or constructors using floats.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
TDK
Guru

The tool settings allow the compiler to generate FPU instructions but you still need to enable it within the code itself.

#if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
  SCB->CPACR |= ((3UL << 10 * 2) |
      (3UL << 11 * 2));  /* set CP10 and CP11 Full Access */
#endif
If you feel a post has answered your question, please click "Accept as Solution".