Ameba-D User Manual
User Manual All information provided in this document is subject to legal disclaimers. © REALTEK 2019. All rights reserved.
228
10.5.2
Synchronous Data from Fast Clock to Slow Clock
The TIMx_ARR can be configured dynamically, it is hard for basic timer to get the correct value of TIMx_ARR since the timer clock of basic timer
is much slower than bus clock. You must latch a safe version of TIMx_ARR for basic timer clock to read.
The cki is fast clock and cko is slow clock. The data_i is data in fast clock domain, which can be changed at any time, and the data_o is the safe
version of data_i for slow clock to read.
cko
…
…
cki
cko_pedge
(ckoàPulse)
safe_indc
clr_safe_ps
(sync_toggle à pulse)
sync_toggle
data_i
data_o
fast clk
domain
fast clk
domain
slow clk
domain
fast clk
domain
fast clk
domain
fast clk
domain
slow clk
domain
fast clk
domain
Fig 10-17 Synchronous data diagram
10.6
Operation Flow
10.6.1
Upcounting Mode
Upcounting mode: support TIM0~TIM5. The configuration flow is listed in Table 10-8.
Table 10-8 Timers upcounting configuration flow
Step What to do
How to do
Comments
1
Check the timer run status
Poll CNT_RUN in TIMx_EN.
If CNT_RUN is 1, go to step 2, else go to step 4
2
Disable the timer
Write “0x02” to TIMx_EN
Stop Counter
3
Check the timer run status
Poll CNT_RUN in TIMx_EN until CNT_RUN is 0
Wait counter to be stopped
4
Set prescaler
Configure TIMx_PSC
5
Set ARR
Configure TIMx_ARR
6
Initialize the counter
Write “0x01” to TIMx_EGR (set UG bit)
Generate UEV by software
7
Check whether the timer is initialized
Poll UG_DONE in TIMx_SR until it is set
Wait counter to be initialized
8
Clear event flag
Write “0x0F” to TIMx_SR
Clear all flags
10
Enable the timer
Set CEN bit in TIMx_CR
Configure UEV condition at the same time
11
Check whether the timer is running
Poll CNT_RUN in TIMx_EN
Optional
12
Change ARR on the fly
Configure TIMx_ARR
Recommend to set ARPE bit in TIMx_CR
Realtek confidential files
The document authorized to
2019-05-15 10:08:03