01.06.2014 Views

STM32W108C8

STM32W108C8

STM32W108C8

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

General-purpose timers<br />

Note:<br />

When the <strong>STM32W108C8</strong> enters debug mode and the ARM® Cortex-M3 core is halted, the<br />

counters continue to run normally.<br />

Prescaler<br />

The prescaler can divide the counter clock frequency by power of two from 1 through 32768.<br />

It is based on a 16-bit counter controlled through the 4-bit TIM_PSCEXP bit field in the<br />

TIMx_PSC register. The factor by which the counter is divided is two raised to the power<br />

TIM_PSCEXP (2TIM_PSCEXP).<br />

It can be changed on the fly as this control register is buffered. The new prescaler ratio is<br />

used starting at the next update event.<br />

Figure 14 gives an example of the counter behavior when the prescaler ratio is changed on<br />

the fly.<br />

Figure 14. Counter timing diagram with prescaler division change from 1 to 4<br />

10.1.2 Counter modes<br />

Up-counting mode<br />

In up-counting mode, the counter counts from 0 to the auto-reload value (contents of the<br />

TIMx_ARR register), then restarts from 0 and generates a counter overflow event.<br />

An update event can be generated at each counter overflow, by setting the TIM_UG bit in<br />

the TIMx_EGR register, or by using the slave mode controller.<br />

Software can disable the update event by setting the TIM_UDIS bit in the TIMx_CR1<br />

register, to avoid updating the shadow registers while writing new values in the buffer<br />

registers. No update event will occur until the TIM_UDIS bit is written to 0. Both the counter<br />

and the prescalar counter restart from 0, but the prescale rate does not change. In addition,<br />

if the TIM_URS bit in the TIMx_CR1 register is set, setting the TIM_UG bit generates an<br />

update event but without setting the INT_TIMUIF flag. Thus no interrupt request is sent. This<br />

avoids generating both update and capture interrupts when clearing the counter on the<br />

capture event.<br />

Doc ID 018587 Rev 2 112/215

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

Saved successfully!

Ooh no, something went wrong!