AN202
V1.0 | Page 59/73
www.cmostek.com
13 Clock Measurement
This function can accurately measure the internal slow clock period.
In this mode, the prescaler and postscaler configuration of TIMER2 is automatically changed to 1:1. They
make up a 12-bit timer. The TIMER2 count clock is the system clock Fosc, not the instruction clock Fosc/2
under the ordinary mode.After the end of the calculation, the result is automatically stored in the SOSCPR
register. The unit is the number of the system clock Fosc.
Operation steps:
1. In order to improve the measurement accuracy, it is suggested that IRCF is set to 111 and SCS is set
to 1, and the system clock of 16M is selected.
2. Set T2CON.2 to 1, enable TIMER2.
3. If selecting the average of the four times, set MSCKCON.2 to 1, and otherwise clear it.
4. Set MSCKCON.1, start measuring.
5. After the end of the measurement, MSCKCON.1 is automatically cleared, and the interrupt flag is set
to 1.
6. The user can end the measurement in a query or interrupt manner.
7. When the interrupt flag is checked to be 1, the read SOSCPR is the final result.
Q
Q
SET
CLR
S
R
Q
Q
SET
CLR
S
R
Q
Q
SET
CLR
S
R
0
1
BUS<1>
MSCKCON WR
CKMAVG
0
1
Q
Q
SET
CLR
S
R
T2 SYSCLK
CKMEAS EN
TMR2
16-bit
SOSCPR<11:0>
SYSCLK
T1
MEAS DONE
To INT
CKCNTI
Figure 13-1. Slow Clock Measurement Mode Block Diagram
Содержание CMT2189C
Страница 32: ...AN202 V1 0 Page 32 73 www cmostek com...