2022-08-19 10:44 PM
I am trying to control a stepper motor with a driver 8825, which is driven by 2 pines DIR and STEP. STEP drives the steps of the motor, it makes an step each time it change its state, so could be driven by a PWM. The idea is to generate an specific amount of pulses through a timer. Using the One Pulse mode and RCR to generate a fixed amount of pulses, I made this code:
---------------------
uint32_t stp = 1;
while (1)
{
Execute_stps(&htim1, stp * 5);
HAL_Delay(10000);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
-------------------
void Execute_stps(TIM_HandleTypeDef *TIMx, uint32_t steps){
//LL_TIM_SetRepetitionCounter(TIMx, steps-1);
TIMx->Init.RepetitionCounter = steps - 1;
__HAL_TIM_SET_AUTORELOAD(TIMx, __HAL_TIM_GET_AUTORELOAD(TIMx)/10);
__HAL_TIM_SET_COMPARE(TIMx, TIM_CHANNEL_2, __HAL_TIM_GET_AUTORELOAD(TIMx)/2);
HAL_GPIO_WritePin(EN_GPIO_Port, EN_Pin, GPIO_PIN_SET);
HAL_Delay(10);
HAL_GPIO_WritePin(EN_GPIO_Port, EN_Pin, GPIO_PIN_RESET);
}
------------------
In order to test the speed my driver and motors are capable of, this function should execute the steps(multiplied by 5 each time the loop starts again) for a motor setting the RCR(here I loaded the number of steps), ARR(divided by 10 each time is called), Compare register (duty cycle 50% = ARR/2), releasing this timer with another gpio pin connected to the ch1 from timer 1, the output comes from ch2 tim1.
The thing is that i already tried it in 2 boards and they both are burned (i think). I uploaded my code, watched that it didn't work, tried to debug with the CubeIDE, and then the IDE started to show this message error:
Error in final launch sequence:
Failed to execute MI command:
target remote localhost:61234
Error message from debugger back end:
localhost:61234: Connection timed out.
Failed to execute MI command:
target remote localhost:61234
Error message from debugger back end:
localhost:61234: Connection timed out.
localhost:61234: Connection timed out.
I tried with other cables, other computers and reinstalling the IDE. Nothing works. I really appreciate if some could help me with this
2022-08-24 09:56 AM
Hello @RonaldJosh ,
Try an upgrade of the ST Link firmware, then connect to ST board and erasing the chip before loading the code. Otherwise, try restart PC, GDB server..
Imen
2022-10-07 06:57 AM
How can I erase the chip?