Ameba-D User Manual
User Manual All information provided in this document is subject to legal disclaimers. © REALTEK 2019. All rights reserved.
196
Input pin
2 input capture
2 input capture
Output pin
-
-
10.2.3
Block Diagram
The block diagram of the pulse timer (TIM4) is shown in Fig 10-2.
CNT counter
PSC
presclaer
Auto-reload register
CK_PSC
Capture/Capture
Register
Statistic pulse number
TRGI
CK_CNT
Fig 10-2 TIM4 block diagram
10.2.4
Functional Description
10.2.4.1
Upcounting Mode
This timer is a 16-bit counter with its related auto-reload register. The counter can count up. The counter clock can be divided by a 8-bit prescaler.
The counter, also the auto-reload register and the prescaler register can be written or read by software. This is true even when the counter is
running.
The time-base unit includes:
Counter register (TIMx_CNT)
Prescaler register (TIMx_PSC)
Auto-reload register (TIMx_ARR)
The auto-reload register is preloaded. Writing to or reading from the auto-reload register accesses the preload register. The contents of the
preload register are transferred into the shadow register permanently or at each update event depending on the ARPE bit in the TIMx_CR register.
The update event is sent when the counter reaches the overflow, and if the UDIS bit equals to 0 in the TIMx_CR register, it can also be generated
by software.
The prescaler can divide the counter clock frequency by any factor between 1 and 256. It is based on a 8-bit counter controlled through a 8-bit
register (in the TIMx_PSC register). It can be changed on the fly as this control register is buffered. The new prescaler ratio is taken into account
at the next update event.
In upcounting mode, the counter counts from 0 to the auto-reload value (the content of the TIMx_ARR register), then restarts from 0 and
generates a counter overflow event.
Setting the UG bit in the TIMx_EGR register by software also generates an update event.
The update event can be disabled by software by setting the UDIS bit in the TIMx_CR register. This is to avoid updating the shadow registers
while writing new values to the preload registers. No update event occurs until the UDIS bit has been written to 0. However, the counter restarts
from 0, as well as the counter of the prescaler
,
but the prescale rate doesn’t change. In addition, if the URS bit in the TIMx_CR register is set,
Realtek confidential files
The document authorized to
SZ99iot
2019-05-15 10:08:03