2025-08-27 11:21 PM
I am using stm32g431c8u6 microcontroller . I have enabled timer 2 channel 3 for alternative pin of PB10 and I have enabled channel 4 for PA3 pin. I set counter perioud 499 and prescaler value =0.
When I plug the debugger and run the code only channel 4 generate PWM signal and channel 3 does not generate PWM signal.
I am using DRV8845 motor drive to control 2 motors. It has two direction pins t control two motors. Below I linked the MCU pin configuration.
This is my code to move forward the 2 motors.
HAL_GPIO_WritePin(GPIOA,GPIO_PIN_2,0);
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_10,1);
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_0,1);
HAL_GPIO_WritePin(GPIOA,GPIO_PIN_7,1);
TIM2->CCR3 = 400; //out_pid;
TIM2->CCR4 = 400;//out_pid;
Please guide me to how to enable PWM signals for both channels. Thank you.
2025-08-27 11:45 PM
Read out and check/post content of TIM and relevant GPIO registers.
JW
2025-08-27 11:54 PM
In above MCU pin configuration timer1 and timer8 are used to count pulse count for encoders and nSLEEP pin is a low power mode pin.
Motor direction pins are PA7 and PB0.
2025-08-28 1:05 AM
I don't think these were information relevant to the problem in original post, i.e. no PWM output signal on PB10 as TIM2_CH3.
Read out and check/post content of TIM2 and GPIOB registers.
JW