Skip to main content
Associate III
July 1, 2025
Question

CubeMX generates new HAL_TIM_PeriodElapsedCallback & deletes everything inside on changing timer

  • July 1, 2025
  • 1 reply
  • 467 views

I have set HAL_IncTick timer (tim6) to not interfere with systick when using thread and RTOS, the new callback was created by cubeMX and I got error about second declaration, I moved my timers settings to newly created callback, later I decided to change to tim18, after code upload I found what some functions do not work like expected, by debugging I found what everything what was in this callback is gone and there is newly created fresh callback just with newly created tim18 settings, everything else is gone ! CubeMX do not checks previously created callback by cubeMX and just deletes it ! 

1 reply

TDK
Super User
July 1, 2025

I think it's expected that user code in a callback which is no longer present/generated will get deleted. It's not going to copy TIM6 code to TIM18.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Associate III
July 1, 2025

User code is between  /* USER CODE BEGIN Callback 0 */  /* USER CODE END Callback 0 */ and I think it must be checked before delete.