Ameba-D User Manual
User Manual All information provided in this document is subject to legal disclaimers. © REALTEK 2019. All rights reserved.
230
Table 10-11 PWM repeated mode configuration flow
Step
What to do
How to do
Comments
1
Disable the timer
Write “0x00” to TIMx_CR
Stop Counter
2
Set prescaler
Configure TIMx_PSC
3
Set ARR
Configure TIMx_ARR
4
Configure PWM mode
Configure CCxM bit in TIMx_CCRx
Configure the level polarity of OCx (CCxP in TIMx_CCRx)
5
Set CCRx
Configure CCRx in TIMx_CCRx
6
Initialize the counter
Write “0x01” to TIMx_EGR (set UG bit)
Generate UEV by software
7
Clear event flag
Write “0x0F” to TIMx_SR
Clear all flags
8
Enable the timer
Set CEN bit in TIMx_CR
Configure UEV condition at the same time
9
Change ARR on-the-fly
Configure TIMx_ARR
Recommend to set ARPE bit in TIMx_CR
10
Change CCRx on-the-fly
Configure CCRx in TIMx_CCRx
Recommend to set OCxPE bit in TIMx_CCRx
10.6.3.2
One-pulse Mode
The TIM5 one-pulse mode configuration flow is illustrated in Table 10-12.
Table 10-12 TIM5 one-pulse mode configuration flow
Step What to do
How to do
Comments
1
Disable the timer
Write “0x00” to TIMx_CR
Stop Counter
2
Set prescaler
Configure TIMx_PSC
3
Set ARR
Configure TIMx_ARR
4
Configure PWM mode
Configure CCxM bit in TIMx_CCRx
Configure the edge polarity of OCx (CCxP in TIMx_CCRx)
5
Set CCRx
Configure CCRx in TIMx_CCRx
6
Initialize the counter
Write “0x01” to TIMx_EGR (set UG bit)
Generate UEV by software
7
Clear event flag
Write “0x0F” to TIMx_SR
Clear all flags
8
Configure the active edge of
input and enable the timer
Configure ETP
Set CEN bit in TIMx_CR
Configure UEV condition at the same
time
10.6.4
Input Capture Mode
Input capture mode: support TIM5. The TIM5 input capture mode configuration flow is illustrated in Table 10-13.
Table 10-13 TIM5 input capture mode configuration flow
Step What to do
How to do
Comments
1
Disable the timer
Write “0x00” to TIMx_CR
Stop Counter
2
Set prescaler
Configure TIMx_PSC
3
Set ARR
Configure TIMx_ARR
4
Configure input capture mode
Configure CCxM bit in TIMx_CCRx
Configure the polarity of TRGI (CCxP in TIMx_CCRx)
5
Initial the counter
Write “0x01” to TIMx_EGR (set UG bit)
Generate UEV by software
6
Clear event flag
Write “0x0F” to TIMx_SR
Clear all flags
7
Enable the timer
Set CEN bit in TIMx_CR
Configure UEV condition at the same
time
8
Read the current value of the
counter when CCxIF is asserted
Read CCRx in TIMx_CCRx
Use interrupt to notify CPU, must
enable CCxIE in TIMx_DIER
9
Clear CCxIF
Write TIMx_SR
In input capture mode, different channels can be used to capture the double edge of TRGI, thus to get the width of TRGI.
Realtek confidential files
The document authorized to
SZ99iot
2019-05-15 10:08:03