Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
General-purpose timers<br />
<strong>STM32W108C8</strong><br />
The GPIOs that can be used by Timer 1 are fixed, but the GPIOs that can be used as Timer<br />
2 channels can be mapped to either of two pins, as shown in Table 83. The Timer 2 Option<br />
Register (TIM2_OR) has four single bit fields (TIM_REMAPCy) that control whether a Timer<br />
2 channel is mapped to its default GPIO in port PA, or remapped to a GPIO in PB.<br />
Table 83 specifies the pins that may be assigned to Timer 1 and Timer 2 functions.<br />
Table 83.<br />
Timer GPIO use<br />
Signal (direction)<br />
TIMxC1<br />
(in or out)<br />
TIMxC2<br />
(in or out)<br />
TIMxC3<br />
(in or out)<br />
TIMxC4<br />
(in or out)<br />
TIMxCLK<br />
(in)<br />
TIMxMSK<br />
(in)<br />
Timer 1 PB6 PB7 PA6 PA7 PB0 PB5<br />
Timer 2<br />
(TIM_REMAPCy = 0)<br />
Timer 2<br />
(TIM_REMAPCy = 1)<br />
PA0 PA3 PA1 PA2 PB5 PB0<br />
PB1 PB2 PB3 PB4 PB5 PB0<br />
The TIMxCLK and TIMxMSK inputs can be used only in the external clock modes: refer to<br />
the External Clock Source Mode 1 and External Clock Source Mode 2 sections for details<br />
concerning their use.<br />
10.1.1 Time-base unit<br />
The main block of the general purpose timer is a 16-bit counter with its related auto-reload<br />
register. The counter can count up, down, or alternate up and down. The counter clock can<br />
be divided by a prescaler.<br />
The counter, the auto-reload register, and the prescaler register can be written to or read by<br />
software. This is true even when the counter is running.<br />
The time-base unit includes:<br />
● Counter register (TIMx_CNT)<br />
● Prescaler register (TIMx_PSC)<br />
● Auto-reload register (TIMx_ARR)<br />
Some timer registers cannot be directly accessed by software, which instead reads and<br />
writes a "buffer register". The internal registers actually used for timer operations are called<br />
"shadow registers".<br />
The auto-reload register is buffered. Writing to or reading from the auto-reload register<br />
accesses the buffer register. The contents of the buffer register are transferred into the<br />
shadow register permanently or at each update event (UEV), depending on the auto-reload<br />
buffer enable bit (TIM_ARBE) in the TIMx_CR1 register. The update event is generated<br />
when both the counter reaches the overflow (or underflow when down-counting) and when<br />
the TIM_UDIS bit equals 0 in the TIMx_CR1 register. It can also be generated by software.<br />
Update event generation 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 (TIM_CEN) in the TIMx_CR1 register is set. Refer also to the slave mode<br />
controller description in the Timers and External Trigger Synchronization section to get more<br />
details on counter enabling.<br />
Note that the actual counter enable signal CNT_EN is set one clock cycle after TIM_CEN.<br />
111/215 Doc ID 018587 Rev 2