2025-02-17 10:57 PM
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.
Solved! Go to Solution.
2025-02-19 05:14 PM
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".
2025-02-19 12:37 AM
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.
2025-02-19 05:14 PM
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".