Showing results for 
Search instead for 
Did you mean: 

TIMx_OCrefClear (stm32F30x)

Associate II
Posted on April 19, 2016 at 21:39

Hello All:

I am tearing my hair out trying to get cycle-by-cycle PWM control working on the Stm32F303RE using the OCRrefClear signal from the comparators.  

PWM working on complimentary channels  (check).

COMP works fine (check).

Connection between the two?  None.  

I have tried this with several devices (303RE, 303R8),  timers (1, 8 , 15, 16, 17) and multiple randomly selected settings.   No joy -- comp output toggles happily, PWM is clean but no shut off using the OCrefClear output.

Has anyone got this to work with the 303?  Or is the OCrefClear some sort of mystical connection.

I am about to give up and try the BRK functions but the pinouts with OCrefClear suits my purposes better.   For one reason on the 303RE ST put the Timer15 output pin on the same pin as it's related COMP3 input, making the combination useless.

Is the BRK connection the only real working one for the F303?   Has anyone got the OCrefClear connection to work with Tim15/16/17? 




Note that this is more rhetorical remarks as I have moved on to using the BRK functions which work as documented.   

I would like to know if the OCrefClear in the reference manuals does actually function or is it some (mis-) information that needs to be removed?   The different part numbers for the F303 family are fairly confusing to begin with but information regarding features that don't appear to exist makes it more difficult to sort through..

Senior II
Posted on April 20, 2016 at 16:33

Hi morgan.doug,

I recommend that you take a look to the application note AN4538 at this



Power consumption optimization with STM32F3xx microcontrollers “

The application note contains a firmware example similar to your application (TIM/PWM, DAC, COMP) where COMP in internally connected to TIM1 OCRrefClear, when signal High it will stop TIM1's PWM generation until signal is low and UEV occurs. You find the firmware at this


Associate II
Posted on April 21, 2016 at 18:04

Thanks Hannibal:

I have my project working great using the break connections between the comparators and the timers so I am happy.  

The software provided for the example cited is for the F302 processors but they do not have enough comparators for the project I am working on so I am using the F303.   

If the appnote software was more straight forward (like pre HAL)I would be tempted to see if it would run on the 303 using the clear input or to verify it works as expected on the F302.   I am using a GCC/eclipse so it is not always simple to get the examples running.  HAL seems to make things worse but that may be a personal problem.

I suspect though that this connection doesn't exist on the F303RE and the references to it in the manual are outdated or only apply to the xC and xD models (none of which I have to test).  Rather than delete this I was going to leave it in the event others ran in to the same problem.