cancel
Showing results for 
Search instead for 
Did you mean: 

Newbie struggling with Complimentary Output of Timer

joeaverage
Associate

Hi,

first foray into STM32 with a Nucleo-F7222ZE.

Using CubeMX I have set up Timer1 to generate PWM. I can get outputs OC1, OC2, OC3 etc, but I cannot get the complementary outputs OC1N, OC2N, OC3N to operate.

 

I feel like I'm missing something, like dead band between OC1 and OC1N for example..

I've tried just about every combination I can think of in CubeMX, with no result so far.

 

Craig

1 ACCEPTED SOLUTION

Accepted Solutions

The correct function to use to start a complementary channel is HAL_TIMEx_PWMN_Start. For example, to start channel TIM1_CH2N:

HAL_TIMEx_PWMN_Start(&htim1, TIM_CHANNEL_2);

 

> HAL_TIM_PWMN_Start

> HAL_TIM1_PWMN_Start

Neither of these are functions that exist in HAL. Perhaps copy/paste to avoid typos.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

8 REPLIES 8
TDK
Super User

Did you try HAL_TIMEx_PWMN_Start? Show your code.

 

Here's a working example:

STM32CubeF7/Projects/STM32756G_EVAL/Examples/TIM/TIM_ComplementarySignals/Src/main.c at 99ad6215a6bd8101a4981137f4a2f06c69e29d37 · STMicroelectronics/STM32CubeF7

If you feel a post has answered your question, please click "Accept as Solution".

Hi,

thanks for your reply, and I rather think you are on to it. I have used this:

HAL_TIM_PWM_Start(&htim1,TIM_CHANNEL_1);

 

to start the timer. Your reply suggests I need to start the complementary output specifically. I'll try it. 

Thanks

Craig

Hi, I have tried:

 

HAL_TIM_PWMN_Start(.....

HAL_TIM1_PWMN_Start(

 

and  get compile errors whenever I try to include either the timer number (1) or the  'N' for complementary

 

Craig

The correct function to use to start a complementary channel is HAL_TIMEx_PWMN_Start. For example, to start channel TIM1_CH2N:

HAL_TIMEx_PWMN_Start(&htim1, TIM_CHANNEL_2);

 

> HAL_TIM_PWMN_Start

> HAL_TIM1_PWMN_Start

Neither of these are functions that exist in HAL. Perhaps copy/paste to avoid typos.

If you feel a post has answered your question, please click "Accept as Solution".

Hi, 

that worked, but I am now confused, I read this in the HAL documentation:

 

HAL_TIM_PWM_Start(...... and that seems to work to start the OC1 output while

HAL_TIMEx_PWM_Start( ........ gives an error.

 

Why is it I use one syntax to start OC1 and another to start OC1N? I can find no mention in  the HAL documentation about this other syntax. Do I have the best available Hal documentation:UM1905

 

Craig

 

 

Hi,

I've found the Timer Extension Driver chapter......so it is included in the documentation that I had, but that I was not looking far enough afield to find it.

Thanks for your help.

 

Craig

> HAL_TIMEx_PWM_Start( ........ gives an error.

This is not a HAL function and therefore does not appear anywhere in UM1905.

TDK_0-1762733136106.png

 

The correct function to use is still HAL_TIMEx_PWMN_Start, which appears in UM1905.

TDK_1-1762733226160.png

 

If you feel a post has answered your question, please click "Accept as Solution".

Hi, 

yes, thanks I have found the relevant section. New syntax is confusing to start with.

 

Craig