上海贝岭股份有限公司
Shanghai Belling Co., Ltd.
BL22P14 USER MANUAL
BM22P14用户手册
1/3 Duty 1/3Bias
5.9 Timer - TIMER0
TIMER0 is an 8bit count-up counter. The counter clock source may come from Fsys or
RTC time-out signal or external source. Using external clock input from TMR0 (PB2)
allows the user to count external events, measure time internals or pulse widths or
generate an accurate time base. While using the internal clock allows the user to generate
an accurate time base.
There is a data register - T0D. Before use, a data must be written to T0D. TIMER0 will
count from $00 to this data and generate an interrupt. Then counter restart from $00.
TIMER0 has three operate mode:
ꢀ
ꢀ
Timer mode The timer clock comes from internal selected clock source.
Event mode To count external signal from TMR0, may count up when the signal
is from low to high or high to low.
ꢀ
Pulse width measure mode To measure pulse width from TMR0. When TE is
“1”, TIMER0 will start counting after TMR0 receives a transient from low to
high(from high to low when TE is “0”) until TMR0 returns to the original level and
resets the TON. (Note: TON is the enable of TIMER0, and only automatic reset
at pulse width measure mode. If other two modes, resetting TON must be
finished by program.) In other words, only one cycle measurement can be made
until TON is set. Then data reading from T0D is the value of pulse width. In the
case of counter overflows, the counter is reload from the counter preload register
and issues an interrupt request as other two modes. And the value of pulse width
TEL:86-21-64850700 WEB: www.belling.com.cn
Page 12 of 33