2019-01-30 03:25 AM
As STM32CubeMX 4.25.1 is not compatible with <X-CUBE-SPN14> Stepper motor driver software expansion for STM32Cube package, i tried to include manualy the Driver to my project. Then, i copy the <BSP> repertory from <en.x-cube-spn14\...\Drivers> to my project Drivers repertory and include it to my Keil's project. i also configurated the Bord pins and Timer (2 and 3) like described in user manual <UM2300> pages (8, 12, 13).
when I compile the project, I have no Warning or Error. I am using a bipolar step Motor with a step angle of 1,8 degree.
when i run the program, the step motor run Forward for 2 run an then Backward for 2 Run and Blocks by runing indefinitely in an <HAL_Delay() > function.
by debugging, i found that the problem occurs on instruction <BSP_MotorControl_SetStopMode(0, HIZ_MODE); at line 306 of main.c file> when a change parameter "HIZ_MODE" to "STANDBY_MODE " the program still occurs. but if i change "HIZ_MODE" to "HOLD_MODE" the Program run but now blocks at instruction <BSP_MotorControl_SetStopMode(0, STANDBY_MODE) ; at line 675 of the main.c file>; here if i change again parameter "STANDBY_MODE" to " "HOLD_MODE", the Program run.
i found that when the second parameter of BSP_MotorControl_SetStopMode() function is "HIZ_MODE", the Device Stop mode is set to "HIZ_MODE" in function <Stspin820_SetStopMode() > at line 1166 of Stspin820.c File. and it allow the Stspin820_StepClockHandler() function to call the Stspin820_HardHiZ() function at line 1831 of stspin820.c file. and the Stspin820_HardHiZ() function call and HAL_Delay() fonction at line 789 of stspin820.c file thanks to Stspin820_Board_Delay() and the call make the Program to blocks indefinitely.
likewise, when the second parameter of BSP_MotorControl_SetStopMode() function is "STANDBY_MODE", that make the Stspin820_StepClockHandler() function calling Stspin820_PutDeviceInStandby() function at line 1827 of stspin820.c file and this function also Call Stspin820_HardHiZ() function wich make program blocking.
To conclude, When i Comment the instruction Stspin820_Board_Delay(DISABLE_DELAY); in Stspin820_HardHiZ() Fonction at line 789, the program run.
Could someone explaine me why this instruction make the Program Blocking?
In attach my Project files.
Solved! Go to Solution.
2019-01-30 06:52 AM
Hey,
I finally solved the problem, the progrem blocked sometime and in interrupt subroutine because i did not configurate in STM32CubeMX the "Timer 2" and "BSP_MOTOR_CONTROL_BOARD_IRQn_EN_AND_FAULT" interrupt request priority to be lower Than "Time base: System tick timer" interrupt request priority and to match like defined in "stm32f4xx_nucleo_ihm14a1.h" file. i did it and now the program run correctly
.
2019-01-30 06:52 AM
Hey,
I finally solved the problem, the progrem blocked sometime and in interrupt subroutine because i did not configurate in STM32CubeMX the "Timer 2" and "BSP_MOTOR_CONTROL_BOARD_IRQn_EN_AND_FAULT" interrupt request priority to be lower Than "Time base: System tick timer" interrupt request priority and to match like defined in "stm32f4xx_nucleo_ihm14a1.h" file. i did it and now the program run correctly
.