Skip to main content
Davi
Associate II
March 21, 2023
Solved

how to only output stm32 pwm CH1N and disable CH1, in "pwm generation CH1 CH1N" mode

  • March 21, 2023
  • 2 replies
  • 7674 views

the below code is not working for me

//HAL_TIM_PWM_Start(&htim15,TIM_CHANNEL_1);

HAL_TIMEx_PWMN_Start(&htim15,TIM_CHANNEL_1);

This topic has been closed for replies.
Best answer by Peter BENSCH

CH1N is controlled by the same channel as CH1, except that CH1N is inverted (we will leave out details such as the dead time required for half bridges for this consideration). If you want to control two DC motors separately, you also need two separate PWM channels, consequently 9 PWM channels for 9 DC motors.

Since we don't know yet which STM32 you want to use, we can't give a hint yet.

Regards

/Peter

2 replies

Foued_KH
ST Employee
March 21, 2023

Hello @Davi​ ,

You can use this code, it works fine:

HAL_TIM_PWM_Start(&htim15, TIM_CHANNEL_1);
HAL_TIMEx_PWMN_Start(&htim15, TIM_CHANNEL_1);

Foued

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Davi
DaviAuthor
Associate II
March 21, 2023
  1. Yes, when enable HAL_TIM_PWM_Start(&htim15, TIM_CHANNEL_1); and HAL_TIMEx_PWMN_Start(&htim15, TIM_CHANNEL_1); then PWMN channel is working,
  2. But I just want to enable CH1N  or CH1 at one time, not enable both CH1N and CH1

Foued_KH
ST Employee
March 21, 2023

I think you should set PWM on CH1 and CH2N :

HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1);
HAL_TIMEx_PWMN_Start(&htim1, TIM_CHANNEL_2);

Foued

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
TDJ
Senior III
October 6, 2023

Briefly, to enable timer on CH1N use HAL_TIMEx_PWMN_Start(), not HAL_TIME_PWM_Start().
I just wasted all evening before I figured this out.