
Page 124
2007-10-15
TMP91FW60
When the double buffer is enabled, data is transferred from the register buffer 0 to the timer register when the
values in the up counter (UC0) and the timer register TB0RG1H/L match.
The double buffer circuit incorporates two flags to indicate whether or not data is written to the lower 8 bits
and the upper 8 bits of the register buffer, respectively. Only when both flags are set can data be transferred
from the register buffer to the timer register by a match between the up-counter UC0 and the timer register
TB0RG1. This data transfer is performed so long as 16-bit data is written in the register buffer regardless of the
register buffer to the timer register unexpectedly as explained below.
For example, let us assume that an interrupt occurs when only the lower 8 bits (L1) of the register buffer data
(H1L1) have been written and the interrupt routine includes writes to all 16 bits in the register buffer and a
transfer of the data to the timer register. In this case, if the higher 8 bits (H1) are written after the interrupt rou-
tine is completed, only the flag for the higher 8 bits will be set, the flag for the lower 8 bits having been cleared
in the interrupt routine. Therefore, even if a match occurs between UC0 and TB0RG1, no data transfer will be
performed.
Then, in an attempt to set the next set of data (H2L2) in the register buffer, when the lower 8 bits (L2) are
written, this will cause the flag for the lower 8 bits to be set as well as the flag for the higher 8 bits which has
been set by writing the previous data (H1). If a match between UC0 and TB0RG1 occurs before the higher 8
bits (H2) are written, this will cause unexpected data (H1L2) to be sent to the timer register instead of the
intended data (H2L2).
To avoid such transfer timing problems due to interrupts, the DI instruction (disable interrupts) and the EI
(enable interrupts) can be executed before and after setting data in the register buffer, respectively.
After a reset, TB0RG0H/L and TB0RG1H/L are undefined. If the 16-bit timer is to be used after a reset, data
should be written to it beforehand.
On a reset <TB0RDE> is initialized to "0", disabling the double buffer. To use the double buffer, write data
to the timer register, set <TB0RDE> to "1", then write data to the register buffer 10 as shown below.
TB0RG0H/L and the register buffer 0 both have the same memory addresses (0188H and 0189H) allocated
to them. If <TB0RDE> = "0", the value is written to both the timer register and the register buffer 0. If
<TB0RDE> = "1", the value is written to the register buffer 0 only.
The addresses of the timer registers are as follows:
Note:The timer registers are write-only registers and thus cannot be read.
TMRB0
TB0RG0H/L
TB0RG1H/L
Upper 8 bits
Lower 8 bits
Upper 8 bits
Lower 8 bits
000189H
000188H
00018BH
00018AH
TMRB1
TB1RG0H/L
TB1RG1H/L
Upper 8 bits
Lower 8 bits
Upper 8 bits
Lower 8 bits
000199H
000198H
00019BH
00019AH
TMRB2
TB2RG0H/L
TB2RG1H/L
Upper 8 bits
Lower 8 bits
Upper 8 bits
Lower 8 bits
0001A9H
0001A8H
0001ABH
0001AAH
TMRB3
TB3RG0H/L
TB3RG1H/L
Upper 8 bits
Lower 8 bits
Upper 8 bits
Lower 8 bits
0001B9H
0001B8H
0001BBH
0001BAH
TMRB4
TB4RG0H/L
TB4RG1H/L
Upper 8 bits
Lower 8 bits
Upper 8 bits
Lower 8 bits
0001C9H
0001C8H
0001CBH
0001CAH