cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103RBT6 complimentary output polarity problem

robertnoble9
Associate III
Posted on October 10, 2016 at 01:11

Hi,

I am trying to get complimentary output working with the same polarity on both the OCx and OCxN.  I have successfully done this with TIM_OCPolarity_High, and TIM_OCNPolarity_Low.  

The next step is to be able to disable and re-enable either the OCx or OCxN outputs.  I am able to set up everything as I want, with the desired polarity on the desired outputs.  However when I disable the OCx output using 

TIM_CCxCmd(TIM1, TIM_Channel_1, TIM_CCx_Disable);

and then re-enable it using

TIM_CCxCmd(TIM1, TIM_Channel_1, TIM_CCx_Enable);

 the OCxN output polarity reverts back to TIM_OCNPolarity_High.  

I am currently using an STM32F103RBT6 Nucleo board with ST Link debugger.

I have checked the CCER register and the OCxN polarity bit is high (=1), but the output is reversed.

If I disable and re-enable the OCxN output, it retains the correct polarity.

Very confused, any help would be great, thanks in advance

Rob
1 REPLY 1
Walid FTITI_O
Senior II
Posted on October 10, 2016 at 11:43

Hi minthemerciless, 

In this case, you should the commutation feature in Timer peripheral. To get more in details about it you can refer to the section 6-PWM generation in STM32F1xx reference manual.

There is the new application note about TIMERS which is

http://www.st.com/content/ccc/resource/technical/document/application_note/group0/91/01/84/3f/7c/67/41/3f/DM00236305/files/DM00236305.pdf/jcr:content/translations/en.DM00236305.pdf

 . The commutation feature is described there and is used in the firmware example ''NpulseWave_TIM_Sync'' that you find in the relevant firmware package 

http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-expansion-software/x-cube-timcooker.html

-Hannibal-