Hello @chriskuku,
You should add the functions in the User Code section:
/* USER CODE BEGIN */
(..)
/* USER CODE END */
Ensure that following option is checked: "Keep User Code when re-generating". In this case, the user sections defined by STM32CubeMX are preserved.
Note that when upgrading to a new version of STM32CubeMX, make sure to always backup your projects before loading the new project (especially when the project includes user code).
I hope that this brings some help to you.
Foued
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.