Skip to main content
Kse.1
Associate
February 18, 2025
Solved

MotorControl Workbench_6.3.2 __weak void MX_MotorControl_Init() ... can be excuetable??

  • February 18, 2025
  • 2 replies
  • 422 views

 

1. using Workbench

"B-G431B-ESC1" board, "Gimbal GBM2804H-100T" motor

2. Generated Code "stm32CubeIDE", drive type: HAL

 

3. CubeIde code.

generated code as below...........

in main(), MX_MotorControl_Init() function can be executable normally?

Shouldn't the "__weak" in front of the function disappear?

Is the code generated properly?

Is there something wrong with the setting?

I generated the code without connecting B-G431B-ESC1.

 

 

main.c
int main(void)
{

..........
MX_TIM2_Init();
MX_MotorControl_Init();

/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */

/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}

 

 

motorcontrol.c

 

__weak void MX_MotorControl_Init(void)

{

/* Reconfigure the SysTick interrupt to fire every 500 us. */

(void)HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq() / SYS_TICK_FREQUENCY);

HAL_NVIC_SetPriority(SysTick_IRQn, uwTickPrio, 0U);

 

/* Initialize the Motor Control Subsystem */

MCboot(pMCI);

mc_lock_pins();

}

 

 

mc_task.c

__weak void MCboot( MCI_Handle_t* pMCIList[NBR_OF_MOTORS] )

{.........}

 

__weak void mc_lock_pins (void)

{.........}

 

 

 

 

........Thank you in advance.

Best answer by Kse.1


I didn't get it right.
The problem has been resolved.

 

filex.h 

     void A();

 

filex.c

__weak void A()

{

   printf("abc");

}

 

main.c

int main()

{

   A();

}

 

result:   abc  ... normally printed


If  A()  is not defined in another file in main.c:
An A() call defined in filex.c is called "abc".

2 replies

GMA
Technical Moderator
February 19, 2025

Hello @Kse.1,
- What do you mean by "in main(), MX_MotorControl_Init() function can be executable normally?"?
- Code generation status is visible on "Project generation" window.

If you agree with the answer, please accept it by clicking on 'Accept as solution'.Best regards.GMA
Kse.1
Kse.1AuthorBest answer
Associate
February 20, 2025


I didn't get it right.
The problem has been resolved.

 

filex.h 

     void A();

 

filex.c

__weak void A()

{

   printf("abc");

}

 

main.c

int main()

{

   A();

}

 

result:   abc  ... normally printed


If  A()  is not defined in another file in main.c:
An A() call defined in filex.c is called "abc".