cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMX and IAR tool chain

curiocity
Associate

Hi, I’m using STM32CubeMX to configure peripherals and IAR Embedded Workbench for debugging. However, I’ve noticed that whenever I regenerate the code using CubeMX, the application code I previously wrote in IAR gets erased.

Is there any setting or configuration in CubeMX that prevents it from overwriting my application code when I regenerate code after making configuration changes?

1 ACCEPTED SOLUTION

Accepted Solutions
Souhaib MAZHOUD
ST Employee

Hello @curiocity 

Keeping your application code inside USER CODE blocks or in separate files is necessary when regenerating code for IAR via CubeMX to prevent it from being overwritten.

KR,

Souhaib

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

4 REPLIES 4
Souhaib MAZHOUD
ST Employee

Hello @curiocity 

Keeping your application code inside USER CODE blocks or in separate files is necessary when regenerating code for IAR via CubeMX to prevent it from being overwritten.

KR,

Souhaib

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hi Souhaib, What do you mean by USER CODE blocks can you elaborate it  

Hello @curiocity 

User code is the sections between USER CODE BEGIN and USER CODE END as shown below:

int main(void)
{

  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* Configure the peripherals common clocks */
  PeriphCommonClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

 

 

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

@Souhaib MAZHOUD Thanks, That helped me