2020-08-02 11:25 PM
Hi everyone,
I have problem when i try to change GPIO inform then i push "generate code". But it replace my old code.
can you let me know how to only update inform for code not replace old code?
thanks you and sory about my poor english!
Solved! Go to Solution.
2020-08-03 11:01 AM
I assume you were creating your code using STM32CubeMX or STM32CubeIDE, right?
Both are based on the same principles and by default should create the project with Keep User Code when re-generating enabled. Please double check your settings by opening the IOC file and navigating to Project Manager > Code Generator --> Keep User Code ...
If you check the generated code, you will find many comment lines like
/* USER CODE BEGIN <block_name> */
...
/* USER CODE END <block_name> */
while <block_name> can be Header, Includes, PTD, PD, etc.
If the above setting is enabled, changing and / or re-creating the project will not change your user code if it is between these comments.
Does it help?
Good luck!
/Peter
2020-08-03 11:01 AM
I assume you were creating your code using STM32CubeMX or STM32CubeIDE, right?
Both are based on the same principles and by default should create the project with Keep User Code when re-generating enabled. Please double check your settings by opening the IOC file and navigating to Project Manager > Code Generator --> Keep User Code ...
If you check the generated code, you will find many comment lines like
/* USER CODE BEGIN <block_name> */
...
/* USER CODE END <block_name> */
while <block_name> can be Header, Includes, PTD, PD, etc.
If the above setting is enabled, changing and / or re-creating the project will not change your user code if it is between these comments.
Does it help?
Good luck!
/Peter
2020-08-03 05:26 PM
Thanks for your reply,
in file IOD i set Project Manager > Code Generator --> Keep User Code ... already.
but old my code is not exist.
for example put 2 code lines as below:
while (1)
{
/* USER CODE END WHILE */
HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_13);
HAL_Delay(200);
/* USER CODE BEGIN 3 */
}
//
when i push generate code again my code not exist only have the code line
/* USER CODE BEGIN <block_name> */
/* USER CODE END <block_name> */
2020-08-03 08:01 PM
Hello @Peter BENSCH ,
After researching i found the reason. Just put the code between 2 lines:
/* USER CODE BEGIN 3 */
/* USER CODE END 3 */
Thanks you!