Skip to main content
Associate III
October 25, 2024
Question

Code deleted after re-generation

  • October 25, 2024
  • 2 replies
  • 943 views

I generated with MC Workbench some code sa use to program an inverter. I want to plot with the monitor the value read from the potentiometer, i.e., the value stored in "rawValue"

I had managed to graphically plot on the monitor "rawValue" variable used only in the two functions "potentiometer.c" and "speed_potentiometer.c" using a variable "pot" declared in main and reported in "potentiometer.c" as external (extern uint16_t pot):

luke514_0-1729863051366.png

The problem is that when I regenerate the code with the .ioc file .. everything I wrote inside this function (fortunately only two lines) is deleted!

How can I do to avoid this problem?

 

 

 

    2 replies

    GMA
    Technical Moderator
    October 28, 2024

    Hello @luke514,

    You have to add this code between these two comment lines (see main.c file as example)

    /* USER CODE BEGIN x */
    new lines
    /* USER CODE END x */

    If you agree with the answer, please accept it by clicking on 'Accept as solution'.Best regards.GMA
    Tesla DeLorean
    Guru
    October 28, 2024

    >>How can I do to avoid this problem?

    Don't regenerate into your primary branch?

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    luke514Author
    Associate III
    October 28, 2024

    Can you explain more in detail?

    Thanks