After any Pin-out modification,, IDE replace main.c with a new one, and all the written code will be deleted !!
Is there a way to change that bad process ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-03 11:25 AM
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-03 11:57 AM
Hello @Enour.1​ ,
In CubeMx for keeping the USER CODE section, you should check "code generator" setting and ensure that you ticked this option "Keep user code when re-generating", as following: Project Manager -> [Code Generator] TAB, then tick "Keep User Code when re-generating"
To protect all the modifications you did, you have to insert your code in the USER CODE sections parts defined in the main file like :
/* USER CODE BEGIN xx */
...
/* USER CODE END xx */
When you modify your configuration with CubeMX, this tool generates a new set of files needed to support your configuration. So all files part of the previous configuration are overwritten. But any code located in those sections is preserved against overwriting. Otherwise the user code is lost.
Hope this helps you.
When your question is answered, please select the Best answer so that this thread will be marked as solved.
Imen
Thanks
Imen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-03 11:57 AM
Hello @Enour.1​ ,
In CubeMx for keeping the USER CODE section, you should check "code generator" setting and ensure that you ticked this option "Keep user code when re-generating", as following: Project Manager -> [Code Generator] TAB, then tick "Keep User Code when re-generating"
To protect all the modifications you did, you have to insert your code in the USER CODE sections parts defined in the main file like :
/* USER CODE BEGIN xx */
...
/* USER CODE END xx */
When you modify your configuration with CubeMX, this tool generates a new set of files needed to support your configuration. So all files part of the previous configuration are overwritten. But any code located in those sections is preserved against overwriting. Otherwise the user code is lost.
Hope this helps you.
When your question is answered, please select the Best answer so that this thread will be marked as solved.
Imen
Thanks
Imen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-03 12:36 PM
Thanks for your reply,
Where can I find that TAB : Project Manager -> [Code Generator] ?
I'm using Stm32cubeIDE workspace 1.4.0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-03 2:31 PM
Hello Imen,
I have already found that TAB Project Manager->Code Generator in the device configuration Tools,
the option "Keep User Code when re-generating" is by default checked, I didn't change change it,
The IDE still behave in the same way, simple code inside while(1) { } block :
while(1){
/* USER CODE BEGIN xx */
...
/* USER CODE END xx */
}
will be lost with any Pin-Out change and code regeneration..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-03 3:18 PM
Hello Imen,
I found this useful video explain it :
https://www.youtube.com/watch?v=hyZS2p1tW-g&feature=emb_logo
At Min 9:40
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-11-04 11:11 AM
Hope you solved your problem!
When your question is answered, please close this thread by marking "Select as Best" the post that helped you or solved your problem.
Imen
Thanks
Imen
