29.01.2015 Views

STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and ...

STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and ...

STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

RM0008<br />

General-purpose timer (TIMx)<br />

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

CK_PSC<br />

CNT_EN<br />

Timer clock = CK_CNT<br />

Counter register<br />

F7<br />

F8 F9 FA FB FC 00<br />

01<br />

Update event (UEV)<br />

Prescaler control register 0 3<br />

Write a new value in TIMx_PSC<br />

Prescaler buffer 0 3<br />

Prescaler counter 0 0 1 2 3 0 1 2 3<br />

14.3.2 Counter modes<br />

upcounting mode<br />

In upcounting mode, the counter counts from 0 to the auto-reload value (content of the<br />

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

An Update event can be generated at each counter overflow or by setting the UG bit in the<br />

TIMx_EGR register (by software or by using the slave mode controller).<br />

The UEV event can be disabled by software by setting the UDIS bit in TIMx_CR1 register.<br />

This is to avoid updating the shadow registers while writing new values in the preload<br />

registers. Then no update event occurs until the UDIS bit has been written to 0. However,<br />

the counter restarts from 0, as well as the counter of the prescaler (but the prescale rate<br />

does not change). In addition, if the URS bit (update request selection) in TIMx_CR1<br />

register is set, setting the UG bit generates an update event UEV but without setting the UIF<br />

flag (thus no interrupt or DMA request is sent). This is to avoid generating both update <strong>and</strong><br />

capture interrupts when clearing the counter on the capture event.<br />

When an update event occurs, all the registers are updated <strong>and</strong> the update flag (UIF bit in<br />

TIMx_SR register) is set (depending on the URS bit):<br />

● The buffer of the prescaler is reloaded with the preload value (content of the TIMx_PSC<br />

register)<br />

● The auto-reload shadow register is updated with the preload value (TIMx_ARR)<br />

The following figures show some examples of the counter behavior for different clock<br />

frequencies when TIMx_ARR=0x36.<br />

Doc ID 13902 Rev 9 323/995

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

Saved successfully!

Ooh no, something went wrong!