in the timer registers increases by one each time an internal clock pulse is received or an external
transition occurs on the external timer pin. The timer will count from the initial value loaded by the
preload register to the full count of FFH for the 8-bit timer or FFFFH for the 16-bit timers at which
point the timer overflows and an internal interrupt signal is generated. The timer value will then be
reset with the initial preload register value and continue counting. Note that to achieve a maximum
full range count of FFH for the 8-bit timer or FFFFH for the 16-bit timers, the preload registers must
first be cleared to all zeros. It should be noted that after power on, the preload registers will be in an
unknown condition.
Note that if the Timer/Event Counters are in an OFF condition and data is written to their preload
registers, this data will be immediately written into the actual counter. However, if the counter is en-
abled and counting, any new data written into the preload data register during this period will re-
main in the preload register and will only be written into the actual counter the next time an
overflow occurs. Note also that when the timer registers are read, the timer clock will be blocked to
avoid errors, however, as this may result in certain timing errors, programmers must take this into
account.
For devices with 16-bit timers, which have both low byte and high byte timer registers, accessing
these registers is carried out in a specific way. It must be noted that when using instructions to
preload data into the low byte register, namely, TMRL, TMR0L or TMR1L, the data will only be
placed in a low byte buffer and not directly into the low byte register. The actual transfer of the data
into the low byte register is only carried out when a write to its associated high byte register,
namely, TMRH, TMR0H or TMR1H, is executed. On the other hand, using instructions to preload
data into the high byte timer register will result in the data being directly written to the high byte reg-
ister. At the same time the data in the low byte buffer will be transferred into its associated low byte
register. For this reason, when preloading data into the 16-bit timer registers, the low byte should
be written first. It must also be noted that to read the contents of the low byte register, a read to the
high byte register must first be executed to latch the contents of the low byte buffer into its associ-
ated low byte register. After this has been done, the low byte register can be read in the normal
way. Note that reading the low byte timer register will only result in reading the previously latched
contents of the low byte buffer and not the actual contents of the low byte timer register.
Timer Control Registers
-
TMRC, TMR0C, TMR1C
The flexible features of the Holtek microcontroller Timer/Event Counters enable them to operate in
three different modes, the options of which are determined by the contents of their respective con-
trol register. For devices with only one timer, the single timer control register is known as TMRC
while for devices with two timers, there are two timer control registers known as TMR0C and
TMR1C. It is the timer control register together with its corresponding timer registers that control
the full operation of the Timer/Event Counters. Before the timers can be used, it is essential that
the appropriate timer control register is fully programmed with the right data to ensure its correct
operation, a process that is normally carried out during program initialization.
To choose which of the three modes the timer is to operate in, either in the timer mode, the event
counting mode or the pulse width measurement mode, bits 7 and 6 of the Timer Control Register,
which are known as the bit pair TM1/TM0, T0M1/T0M0 or T1M1/T1M0 respectively, depending
upon which timer is used, must be set to the required logic levels. The timer-on bit, which is bit 4 of
the Timer Control Register and known as TON, T0ON or T1ON, depending upon which timer is
Chapter 1 Hardware Structure
37
Summary of Contents for HT46R22
Page 7: ...vi A D Type MCU...
Page 9: ...viii A D Type MCU...
Page 10: ...P a r t I Microcontroller Profile Part I Microcontroller Profile 1...
Page 11: ...2 A D Type MCU...
Page 90: ...P a r t I I Programming Language Part II Programming Language 81...
Page 91: ...82 A D Type MCU...
Page 97: ...88 A D Type MCU...
Page 128: ...P a r t I I I Development Tools Part III Development Tools 119...
Page 129: ...120 A D Type MCU...
Page 140: ...Appendix Appendix 131...
Page 141: ...132 A D Type MCU...
Page 151: ...142 A D Type MCU...
Page 152: ...A p p e n d i x B Package Information Appendix B Package Information 143 B...
Page 161: ...A D Type MCU...
Page 162: ...Amendments...