Skip to main content
Associate III
December 17, 2023
Solved

FPU is not initialized

  • December 17, 2023
  • 4 replies
  • 8603 views

/**
******************************************************************************
* @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

 

    This topic has been closed for replies.
    Best answer by AScha.3

    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

     

    4 replies

    AScha.3
    AScha.3Best answer
    Super User
    December 17, 2023

    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 on " Best Answer ".
    Piranha
    Principal III
    December 17, 2023

    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.

    Tesla DeLorean
    Guru
    December 17, 2023

    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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
    TDK
    December 17, 2023

    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""."