2025-11-09 12:58 PM
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
Solved! Go to Solution.
2025-11-09 2:02 PM
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.
2025-11-09 1:06 PM - edited 2025-11-09 1:06 PM
Did you try HAL_TIMEx_PWMN_Start? Show your code.
Here's a working example:
2025-11-09 1:11 PM
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
2025-11-09 1:57 PM
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
2025-11-09 2:02 PM
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.
2025-11-09 3:33 PM
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
2025-11-09 3:40 PM
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
2025-11-09 4:07 PM
> HAL_TIMEx_PWM_Start( ........ gives an error.
This is not a HAL function and therefore does not appear anywhere in UM1905.
The correct function to use is still HAL_TIMEx_PWMN_Start, which appears in UM1905.
2025-11-09 4:11 PM
Hi,
yes, thanks I have found the relevant section. New syntax is confusing to start with.
Craig