STM32W108C8

STM32W108C8 STM32W108C8

01.06.2014 Views

General-purpose timers STM32W108C8 10 General-purpose timers Each of the STM32W108C8's two general-purpose timers consists of a 16-bit auto-reload counter driven by a programmable prescaler. They may be used for a variety of purposes, including measuring the pulse lengths of input signals (input capture) or generating output waveforms (output compare and PWM). Pulse lengths and waveform periods can be modulated from a few microseconds to several milliseconds using the timer prescaler. The timers are completely independent, and do not share any resources. They can be synchronized together as described in Section 10.1.14: Timer synchronization on page 136. Note: The two general-purpose timers, TIM1 and TIM2, have the following features: ● 16-bit up, down, or up/down auto-reload counter. ● Programmable prescaler to divide the counter clock by any power of two from 1 through 32768. ● 4 independent channels for: – Input capture – Output compare ● PWM generation (edge- and center-aligned mode) ● One-pulse mode output ● Synchronization circuit to control the timer with external signals and to interconnect the timers. ● Flexible clock source selection: – Peripheral clock (PCLK at 6 or 12 MHz) – 32 kHz external clock (if available) – 1 kHz clock ● GPIO input ● Interrupt generation on the following events: – Update: counter overflow/underflow, counter initialization (software or internal/external trigger) – Trigger event (counter start, stop, initialization or count by internal/external trigger) ● Input capture ● Output compare ● Supports incremental (quadrature) encoders and Hall sensors for positioning applications. ● Trigger input for external clock or cycle-by-cycle current management. Because the two timers are identical, the notation TIMx refers to either TIM1 or TIM2. For example, TIMx_PSC refers to both TIM1_PSC and TIM2_PSC. Similarly, "y" refers to any of the four channels of a given timer, so for example, OCy refers to OC1, OC2, OC3, and OC4. 109/215 Doc ID 018587 Rev 2

STM32W108C8 General-purpose timers Figure 13. General-purpose timer block diagram Note: The internal signals shown in Figure 13 are described in Section 10.1.15: Timer signal descriptions on page 140 and are used throughout the text to describe how the timer components are interconnected. 10.1 Functional description The timers can optionally use GPIOs in the PA and PB ports for external inputs or outputs. As with all STM32W108C8 digital inputs, a GPIO used as a timer input can be shared with other uses of the same pin. Available timer inputs include an external timer clock, a clock mask, and four input channels. Any GPIO used as a timer output must be configured as an alternate output and is controlled only by the timer. Many of the GPIOs that can be assigned as timer outputs can also be used by another onchip peripheral such as a serial controller. Use as a timer output takes precedence over another peripheral function, as long as the channel is configured as an output in the TIMx_CCMR1 register and is enabled in the TIMx_CCER register. Doc ID 018587 Rev 2 110/215

General-purpose timers<br />

<strong>STM32W108C8</strong><br />

10 General-purpose timers<br />

Each of the <strong>STM32W108C8</strong>'s two general-purpose timers consists of a 16-bit auto-reload<br />

counter driven by a programmable prescaler. They may be used for a variety of purposes,<br />

including measuring the pulse lengths of input signals (input capture) or generating output<br />

waveforms (output compare and PWM). Pulse lengths and waveform periods can be<br />

modulated from a few microseconds to several milliseconds using the timer prescaler. The<br />

timers are completely independent, and do not share any resources. They can be<br />

synchronized together as described in Section 10.1.14: Timer synchronization on page 136.<br />

Note:<br />

The two general-purpose timers, TIM1 and TIM2, have the following features:<br />

● 16-bit up, down, or up/down auto-reload counter.<br />

● Programmable prescaler to divide the counter clock by any power of two from 1 through<br />

32768.<br />

● 4 independent channels for:<br />

– Input capture<br />

– Output compare<br />

● PWM generation (edge- and center-aligned mode)<br />

● One-pulse mode output<br />

● Synchronization circuit to control the timer with external signals and to interconnect the<br />

timers.<br />

● Flexible clock source selection:<br />

– Peripheral clock (PCLK at 6 or 12 MHz)<br />

– 32 kHz external clock (if available)<br />

– 1 kHz clock<br />

● GPIO input<br />

● Interrupt generation on the following events:<br />

– Update: counter overflow/underflow, counter initialization (software or<br />

internal/external trigger)<br />

– Trigger event (counter start, stop, initialization or count by internal/external trigger)<br />

● Input capture<br />

● Output compare<br />

● Supports incremental (quadrature) encoders and Hall sensors for positioning<br />

applications.<br />

● Trigger input for external clock or cycle-by-cycle current management.<br />

Because the two timers are identical, the notation TIMx refers to either TIM1 or TIM2. For<br />

example, TIMx_PSC refers to both TIM1_PSC and TIM2_PSC. Similarly, "y" refers to any of<br />

the four channels of a given timer, so for example, OCy refers to OC1, OC2, OC3, and OC4.<br />

109/215 Doc ID 018587 Rev 2

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!