HT45R38
data and the contents of the low byte buffer into the
Timer A/Timer B (16-bit) simultaneously. Timer A/Timer
B is changed by writing to TMRAH/TMRBH but writing to
TMRAL/TMRBL will keep the Timer A/Timer B un-
changed.
The resistor and capacitor form an oscillation circuit and
input to TMRBH and TMRBL. The RCOM0, RCOM1
and RCOM2 bits of RCOCCR define the clock source of
Timer A. It is recommended that the clock source of
Timer A uses the system clock or the instruction clock.
Reading TMRAH/TMRBH will also latch the
TMRAL/TMRBL into the low byte buffer to avoid the
false timing problem. Reading TMRAL/TMRBL returns
the contents of the low byte buffer. In other word, the low
byte of Timer A/Timer B can not be read directly. It must
read the TMRAH/TMRBH first to ensure that the low
byte contents of Timer A/Timer B are latched into the
buffer.
If the RCOCON bit, bit 4 of RCOCCR, is set to ²1², Timer
A and Timer B will start counting until Timer A or Timer B
overflows, the timer/event counter will then generate an
interrupt request flag which is RCOCF; bit 4 of INTC1.
The Timer A and Timer B will stop counting and will reset
the RCOCON bit to ²0² at the same time. If the
RCOCON bit is ²1², TMRAH, TMRAL, TMRBH and
TMRBL cannot be read or written.
External RC oscillation converter mode example program - Timer A overflow:
clr RCOCCR
mov a, 00000010b
mov RCOCR,a
clr intc1.4
; Enable External RC oscillation mode and set Timer A overflow
; Clear External RC Oscillation Converter interrupt request flag
; Give timer A initial value
mov a, low (65536-1000)
mov tmral, a
mov a, high (65536-1000)
mov tmrah, a
mov a, 00h
; Timer A count 1000 time and then overflow
; Give timer B initial value
mov tmrbl, a
mov a, 00h
mov tmrbh, a
mov a, 00110000b
mov RCOCCR, a
p10:
; Timer A clock source=fSYS/4 and timer on
clr wdt
snz intc1.4
; Polling External RC Oscillation Converter interrupt request flag
jmp p10
clr intc1.4
; Clear External RC Oscillation Converter interrupt request flag
; Program continue
Rev. 1.00
19
December 13, 2006