2021-07-05 06:33 AM
Using a Nucleo f401re nucleo board with a 'X-NUCLEO-IHM03A1' shield that houses a powerSTEP01 stepper motor driver. I've downloaded and run the example projects from 'X-CUBE-SPN3' by ST and the stepper motor runs perfectly. I then generated my own projected with CUBEMX and imported all the driver header and source files in this project. All peripherals are initialized correctly and the physical wiring connections havent changed.
When i run the project, the motor doesnt move and upon debugging line by line, program execution pauses forever after setting the 'X-NUCLEO-IHM03A1' reset pin high. This only happens when the battery (3S LiPo) is connected to Vin, When there is no battery program execution runs fine (using a logic analyzer i can see all SPI signals sending through correctly) but obviously the motor wont run.
Below is the function to initialize the peripherals and stepper motor driver that gets called in main.c
void Powerstep01_Init(void* pInit)
{
/* Initialise the GPIOs of the just added device */
Powerstep01_Board_GpioInit(powerstep01DriverInstance);
if(Powerstep01_Board_SpiInit() != 0)
{
/* Initialization Error */
Powerstep01_ErrorHandler(POWERSTEP01_ERROR_0);
}
/* configure the step clock */
Powerstep01_Board_StepClockInit();
/* Standby-reset deactivation */
Powerstep01_Board_ReleaseReset(powerstep01DriverInstance);
/* Let a delay after reset */
Powerstep01_Board_Delay(1);
if (pInit == 0)
{
// Set all registers to their predefined values from powerstep01_target_config.h
Powerstep01_SetRegisterToPredefinedValues(powerstep01DriverInstance);
}
After Line 16, the program will get stuck on Line 20 forever. Powerstep01_Board_ReleaseReset(powerstep01DriverInstance) just sets the reset pin high:
void Powerstep01_Board_ReleaseReset(uint8_t deviceId)
{
HAL_GPIO_WritePin(BSP_MOTOR_CONTROL_BOARD_STBY_RESET_PORT, BSP_MOTOR_CONTROL_BOARD_STBY_RESET_PIN, GPIO_PIN_SET);
}
I have no idea how the battery is affecting program execution, as everything works in the original example project and motor runs (both projects have the same main.c).
What could be any possible causes?
I can send the project files through if necessary.