General-purpose timer (TIM14)
17.3.6
Forced output mode
In output mode (CCxS bits = '00' in the TIMx_CCMRx register), each output compare signal
(OCxREF and then OCx) can be forced to active or inactive level directly by software,
independently of any comparison between the output compare register and the counter.
To force an output compare signal (OCXREF/OCx) to its active level, you just need to write
'101' in the OCxM bits in the corresponding TIMx_CCMRx register. Thus OCXREF is forced
high (OCxREF is always active high) and OCx get opposite value to CCxP polarity bit.
For example: CCxP='0' (OCx active high) => OCx is forced to high level.
The OCxREF signal can be forced low by writing the OCxM bits to '100' in the TIMx_CCMRx
register.
The comparison between the TIMx_CCRx shadow register and the counter is still performed
and allows the flag to be set. Interrupt requests can be sent accordingly. This is described in
the output compare mode section below.
17.3.7
Output compare mode
This function is used to control an output waveform or to indicate when a period of time has
elapsed.
When a match is found between the capture/compare register and the counter, the output
compare function:
1.
Assigns the corresponding output pin to a programmable value defined by the output
compare mode (OCxM bits in the TIMx_CCMRx register) and the output polarity (CCxP
bit in the TIMx_CCER register). The output pin can keep its level (OCXM='000'), be set
active (OCxM='001'), be set inactive (OCxM='010') or can toggle (OCxM='011') on
match.
2.
Sets a flag in the interrupt status register (CCxIF bit in the TIMx_SR register).
3.
Generates an interrupt if the corresponding interrupt mask is set (CCXIE bit in the
TIMx_DIER register).
The TIMx_CCRx registers can be programmed with or without preload registers using the
OCxPE bit in the TIMx_CCMRx register.
In output compare mode, the update event UEV has no effect on OCxREF and OCx output.
The timing resolution is one count of the counter. Output compare mode can also be used to
output a single pulse (in One-pulse mode).
Procedure:
1.
Select the counter clock (internal, external, prescaler).
2.
Write the desired data in the TIMx_ARR and TIMx_CCRx registers.
3.
Set the CCxIE bit if an interrupt request is to be generated.
4.
Select the output mode. For example:
–
–
–
–
5.
Enable the counter by setting the CEN bit in the TIMx_CR1 register.
362/742
Write OCxM = '011' to toggle OCx output pin when CNT matches CCRx
Write OCxPE = '0' to disable preload register
Write CCxP = '0' to select active high polarity
Write CCxE = '1' to enable the output
Doc ID 018940 Rev 1
RM0091
Need help?
Do you have a question about the STM32F05 series and is the answer not in the manual?
Questions and answers