cancel
Showing results for 
Search instead for 
Did you mean: 

Bi-Directional Motor Control using PWM in STM32F1

Keyshav Mor
Associate II
Posted on March 27, 2017 at 07:46

Hello everyone,

I am trying to reverse the motor direction using PWM from the STM32F1 Series controller and using the L293D Motor driver. I have referred to the bi-directional motor control circuit given in l293d datasheet and done connections accordingly. The following is a snippet of the code which I have used to try the direction control.

Please feel free to point out my mistake.

Thanks.

HAL_TIM_PWM_Start(&htim2,TIM_CHANNEL_2);

HAL_TIM_PWM_Start(&htim2,TIM_CHANNEL_3);

__HAL_TIM_SetCompare(&htim2,TIM_CHANNEL_2,1000);

__HAL_TIM_SetCompare(&htim2,TIM_CHANNEL_3,0);

HAL_Delay(10000);

__HAL_TIM_SetCompare(&htim2,TIM_CHANNEL_2,0);

__HAL_TIM_SetCompare(&htim2,TIM_CHANNEL_3,1000);

HAL_Delay(10000);

#stm32 #nucleo #pwm #motor #control
0 REPLIES 0