cancel
Showing results for 
Search instead for 
Did you mean: 

IHM01A1 Shield project - How to create from scratch?

MDaub.1
Associate III

I am using a IHM01A1 Stepper motor shield with an STM32F401. The provided example for one motor from the X-CUBE-SPN1 package works as expected and I can properly control the motor.

Now I want to basically recreate the project from scratch as a prober STM32CubeIDE project with CubeMX/IOC files.

I spend literally hours for doing this, until everything combined properly as I was adding all the driver folders by hand and had to remove the drivers for all other boards except the F401RE (Linked folder in C-Project Options).

I have now an example which compiles and links without errors, but it doesn't run properly.

This is basically my main.c

int main(void)
{
 HAL_Init();
 SystemClock_Config();
 MX_GPIO_Init();
 MX_USART2_UART_Init();
 MX_TIM3_Init();
 
 char *tmp_string = "Hello world\n";
 BSP_MotorControl_SetNbDevices(BSP_MOTOR_CONTROL_BOARD_ID_L6474, 1);  
 BSP_MotorControl_Init(BSP_MOTOR_CONTROL_BOARD_ID_L6474, 0);
 while (1)
 {
	 HAL_UART_Transmit(&huart2, (uint8_t*) tmp_string, strlen(tmp_string), HAL_MAX_DELAY);
	 BSP_MotorControl_GoTo(0, 1000);
	 BSP_MotorControl_WaitWhileActive(0);
	 BSP_MotorControl_GoTo(0, -1000);
	 BSP_MotorControl_WaitWhileActive(0); 
 }
}

I've traced the execution in the debugger. The code hangs within BSP_MotorControl_Init() and in there in the call to L6474_Board_Delay(1) - which does nothing more then HAL_Delay(1).

Funny enough I cannot step (F5) into L6474_Board_Delay() in the debugger.

And - when I do a HAL_Delay(1) BEFORE the call to BSP_MotorControl_Init(), this one works as expected and returns immediately.

This is my first try to setup a project with that shield so I might have done something fundamentally wrong (I basically added all necessary folders in the BSP subfolder of the SPN1 package to my project, added paths, etc.) as it seems I cannot add this extension via the IDE automatically.

I already verified that the clock settings are 1:1 between the examples.

What could be wrong. Project attached for your reference.

Thank you

0 REPLIES 0