cancel
Showing results for 
Search instead for 
Did you mean: 

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

SWenn.1
Senior III

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Bob S
Principal

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

View solution in original post

2 REPLIES 2
Bob S
Principal

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

Thank you...