Skip to main content
Kse.1
Associate
Solved

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

 

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.

This topic has been closed for replies.
Kse.1
Kse.1Best answer
Associate


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
ST Technical Moderator

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 'Best answer'.Best regards.GMA
Kse.1
Kse.1AuthorBest answer
Associate


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".