Skip to main content
Glenn Rosendahl
Associate II
February 20, 2018
Question

MDK & HAL & __attribute

  • February 20, 2018
  • 2 replies
  • 710 views
Posted on February 20, 2018 at 19:36

I'm using the STM32CUBEMX which generates HAL code and keeps my code within defined comments. BUT, I need to define an __attribute statement BEFORE a HAL generated function header, but there is no /* USER CODE .. */ place to hold these statements so they get wiped with every STM32CUBEMX project update. Any solutions??

Many Thanks, Glenn

    This topic has been closed for replies.

    2 replies

    John Craven
    Senior
    February 20, 2018
    Posted on February 20, 2018 at 22:08

    Its a bit of a sledgehammer approach, but it works in some cases;

    And i apologized in advance to all those it really offends! LOL

    Suppose you have something like this, and you want to change or add something in the 3 init calls;

     /* USER CODE BEGIN SysInit */
     /* USER CODE END SysInit */
     /* Initialize all configured peripherals */
     MX_GPIO_Init();
     MX_TIM2_Init();
     MX_TIM1_Init();
     /* USER CODE BEGIN 2 */
     /* USER CODE END 2 */

    you can undefine a section of Cube Code between user code sections;

    regenerating with Cube will leave your tweaks in place.

     /* USER CODE BEGIN SysInit */
     MX_GPIO_Init();
     MX_TIM2_Init();
     //add new thing here or add attribute to something
     MX_TIM1_Init();
    #ifdef nothing
     /* USER CODE END SysInit */
     /* Initialize all configured peripherals */
     MX_GPIO_Init();
     MX_TIM2_Init();
     MX_TIM1_Init();
     /* USER CODE BEGIN 2 */
    #endif
     /* USER CODE END 2 */

    Tesla DeLorean
    Guru
    February 20, 2018
    Posted on February 21, 2018 at 00:21

    Where you have important work build from a sandbox and merge back in changes from a CubeMX build iteration. Or automate patching with a script as appropriate.

    WinMerge, Araxis Merge

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..