2018-08-15 05:21 PM
In the latest version of STM32CubeMX(4.26.1) and the latest ST Libs for STM32F4 (1.21.0), I've found an issue with USER_write. STM32CubeMX overwrites the user code within the USER_write function between the /* USER CODE BEGIN WRITE */ and /* USER CODE END WRITE */ lines. This results in my code be stomped each time I export my project.
Please note that my custom code within the other USER_xxxxx functions in that module does NOT get overwritten.
One additional note, there is an extraneous /* USER CODE HERE */ line that follows the /* USER CODE BEGIN WRITE */ in USER_write. Perhaps a clue?
I hope you can fix this by the next release.
Thanks,
Craig
2018-08-16 07:50 AM
Hello @Community member ,
I'm not able to reproduce your issue. The user code is kept after regenerating the project using STM32CubeMX.
Please make sure that the "Keep User code when re-generating" is ticked (see attached screenshot).
Otherwise, please share your ioc file.
Khouloud.
2018-08-16 10:43 AM
Thanks Khouloud for your reply. After looking more carefully at my code I figured out what the issue is. I have a second more specialized version of the USER_write function up in top user code section of the file. That second function also has the /* USER CODE BEGIN WRITE */ and /* USER CODE END WRITE */
in it. So when CubeMX is generating the project code, it encounters the first /* USER CODE BEGIN WRITE */ + /* USER CODE END WRITE */ and saves the code between them, then writes out that code there and in my normal USER_write function later in the code. Basically have two /* USER CODE BEGIN WRITE */ + /* USER CODE END WRITE */ pairs in the module was screwing things up. There's no reason for me to have those in my specialized version of the function, so I have removed them and things now work as expected.
Sorry, this was all on me. Sorry for wasting your time.
Thanks,
Craig
2018-08-17 02:06 AM
Hi Craig,
Happy that your issue is solved and thanks for the explanation.
Just note that trying to solve our customer issues is never a waste of time for us. You're always welcome :smiling_face_with_smiling_eyes:
Please do not hesitate to post your questions here on our STM32MCUs forum!
Khouloud.