Skip to main content
Hamidreza Mirtaheri
Visitor II
February 19, 2018
Question

Keep user codes

  • February 19, 2018
  • 4 replies
  • 785 views
Posted on February 19, 2018 at 12:13

How can one keep the custom codes in a subroutine where there is no by default a special place for it?

For instance I'm using 

MX_TIM1_Init(void)

in which there is no dedicated space for my codes such as

/* USER CODE BEGIN MX_TIM1_Init*/ 

or something like this.

I tried to put it in different way by naming it as 

/* USER CODE BEGIN MX_TIM1_Init*/ , 

/* USER CODE BEGIN 10*/   etc

.

Bit still my codes are being deleted after a restart.

    This topic has been closed for replies.

    4 replies

    Houda GHABRI
    ST Employee
    April 20, 2018
    Posted on April 20, 2018 at 17:04

    Hi,

    Can you tell me please  where you want exactly to add the new user section, and why the existing ones are not enough?

    Regards,

    Houda

    Tesla DeLorean
    Guru
    April 20, 2018
    Posted on April 20, 2018 at 17:18

    You might try to edit that without formatting.

    More generally the request would be for automated tools to leave whatever regions of the file are that are explicitly marked with BEGIN/END USER regions alone. The user shouldn't need a 'why', and the tool shouldn't have inflexibility in how it imports/merges boiler plate code.

    Automated tools might want to identify and log area of user inserted code if it is not marked properly, or place it within comments. Code being damaged/destroyed is a high frequency complaint in the forum, the tools should 'do no harm' where at all possible.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Pavel A.
    April 20, 2018
    Posted on April 20, 2018 at 17:39

    But then, why can't we wish a complete AI tool that writes the code for us? It's close ...