Skip to main content
SWenn.1
Senior III
March 13, 2023
Solved

CubeIDE --- How to change .ioc file to update another file??

  • March 13, 2023
  • 1 reply
  • 2075 views

Good morning.....

I have a CubeIDE prj with .ioc and main. All compiles fine. I have created a second file with a main function (gfsk.c). I have excluded the original main.c for build. I would like to know when I go back into the .ioc to make a small change how do I get it to update the new gfsk.c file??? Where is the pointer to this in the IDE? I am finding that if I update the .ioc file in continually updates the old main.c file.

    This topic has been closed for replies.
    Best answer by Bob S

    You can't. CubeMX (standalone or within CubeIDE) is hard-coded to generate main.c. If you want to use a different "main" you will need to manually merge CubeMX's changes in main.c into your gfsk.c. Or, keep your non-Cube code in gfsk.c, renaming its main() to something else, then add a line in main.c (between the "USER" comments) calling your function. For example:

    /* USER CODE BEGIN WHILE */
    while (1)
    {
     my_gfsk_main(); // <----- ADD THIS LINE HERE
     /* USER CODE END WHILE */
     
     /* USER CODE BEGIN 3 */
    }
    /* USER CODE END 3 */

    1 reply

    Bob S
    Bob SBest answer
    Super User
    March 13, 2023

    You can't. CubeMX (standalone or within CubeIDE) is hard-coded to generate main.c. If you want to use a different "main" you will need to manually merge CubeMX's changes in main.c into your gfsk.c. Or, keep your non-Cube code in gfsk.c, renaming its main() to something else, then add a line in main.c (between the "USER" comments) calling your function. For example:

    /* USER CODE BEGIN WHILE */
    while (1)
    {
     my_gfsk_main(); // <----- ADD THIS LINE HERE
     /* USER CODE END WHILE */
     
     /* USER CODE BEGIN 3 */
    }
    /* USER CODE END 3 */

    SWenn.1
    SWenn.1Author
    Senior III
    March 13, 2023

    Thank you...