cancel
Showing results for 
Search instead for 
Did you mean: 

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

Davi
Associate II

the below code is not working for me

//HAL_TIM_PWM_Start(&htim15,TIM_CHANNEL_1);

HAL_TIMEx_PWMN_Start(&htim15,TIM_CHANNEL_1);

1 ACCEPTED SOLUTION

Accepted Solutions

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

In order 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.

View solution in original post

10 REPLIES 10
Foued_KH
ST Employee

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.

  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

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.

Davi
Associate II

The problem is I have 9 DC motor, all motors are need pwm,

so I want to use CH1 and CH1N seperatly to control 2 motor

can I do this?

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

In order 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
Associate II

Thank you, STM32G070RB

With the STM32G070RB you are able to control up to 10 PWM channels:

  • TIM1, ch1...4
  • TIM3, ch1...4
  • TIM15, ch 1...2

Think that's enough for your 9 motors?

Regards

/Peter

In order 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
Associate II

yes, thank you very much​

You're welcome!

When your question is answered, please mark this topic as answered by choosing Select as Best for the preferred answer, as also explained here. This will help other users find that answer faster.

Good luck!

/Peter

In order 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.