29.01.2015 Views

STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and ...

STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and ...

STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

General-purpose timer (TIMx)<br />

RM0008<br />

The auto-reload register is preloaded. Writing to or reading from the auto-reload register<br />

accesses the preload register. The content of the preload register are transferred into the<br />

shadow register permanently or at each update event (UEV), depending on the auto-reload<br />

preload enable bit (ARPE) in TIMx_CR1 register. The update event is sent when the counter<br />

reaches the overflow (or underflow when downcounting) <strong>and</strong> if the UDIS bit equals 0 in the<br />

TIMx_CR1 register. It can also be generated by software. The generation of the update<br />

event is described in detail for each configuration.<br />

The counter is clocked by the prescaler output CK_CNT, which is enabled only when the<br />

counter enable bit (CEN) in TIMx_CR1 register is set (refer also to the slave mode controller<br />

description to get more details on counter enabling).<br />

Note that the actual counter enable signal CNT_EN is set 1 clock cycle after CEN.<br />

Prescaler description<br />

The prescaler can divide the counter clock frequency by any factor between 1 <strong>and</strong> 65536. It<br />

is based on a 16-bit counter controlled through a 16-bit register (in the TIMx_PSC register).<br />

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

taken into account at the next update event.<br />

Figure 100 <strong>and</strong> Figure 101 give some examples of the counter behavior when the prescaler<br />

ratio is changed on the fly:<br />

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

CK_PSC<br />

CNT_EN<br />

Timer clock = CK_CNT<br />

Counter register<br />

F7<br />

F8 F9 FA FB FC<br />

00<br />

01 02 03<br />

Update event (UEV)<br />

Prescaler control register 0 1<br />

Write a new value in TIMx_PSC<br />

Prescaler buffer 0 1<br />

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

322/995 Doc ID 13902 Rev 9

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

Saved successfully!

Ooh no, something went wrong!