Associate III
December 18, 2023
Solved
Motor Pilot
- December 18, 2023
- 3 replies
- 2640 views
I have an issue when using both PWMs generated by timers TIM2 and TIM3 to control two motors simultaneously. Specifically, when I call the function DC_MOTOR_Init(0), it activates PWM1, and when I call DC_MOTOR_Init(1), it activates PWM2. However, if I call both DC_MOTOR_Init(0) and DC_MOTOR_Init(1) simultaneously, they don't seem to work together. When I call either function alone, it works correctly, but when I attempt to call them simultaneously, there is an issue. Despite the fact that the two timers do not share common resources..
#include "main.h"
#include "DC_MOTOR.h"
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
DC_MOTOR_Init(1);
DC_MOTOR_Init(0);
/
while (1)
{
}
