ht82m75r Holtek Semiconductor Inc., ht82m75r Datasheet - Page 18

no-image

ht82m75r

Manufacturer Part Number
ht82m75r
Description
I/o Type 8-bit Otp Mcu
Manufacturer
Holtek Semiconductor Inc.
Datasheet
an initial high output value unless the associated data
registers are first programmed. Selecting which pins are
inputs and which are outputs can be achieved byte-wide
by loading the correct value into the port control register
or by programming individual bits in the port control reg-
ister using the SET [m].i and CLR [m].i instructions.
Note that when using these bit control instructions, a
read-modify-write operation takes place. The
microcontroller must first read in the data on the entire
port, modify it to the required new bit values and then re-
write this data back to the output ports.
All I/O have the additional capability of providing
wake-up functions. When the device is in the Power
Down Mode, various methods are available to wake the
device up. One of these is a high to low and low to high
transition of any of the selected wake-up pins.
Timer/Event Counters
The provision of timers form an important part of any
microcontroller giving the designer a means of carrying
out time related functions. The device contains an inter-
nal 16-bit count-up timer which has three operating
modes. The timer can be configured to operate as a
general timer, external event counter or as a pulse width
measurement device.
There are three registers related to the Timer/Event
Counter, TMRL, TMRH and TMRC. The TMRL/TMRH
register pair are the registers that contains the actual
timing value. Writing to this register pair places an initial
starting value in the Timer/Event Counter preload regis-
ter while reading retrieves the contents of the
Timer/Event Counter. The TMRC register is a
Timer/Event Counter control register, which defines the
timer options, and determines how the timer is to be
used. The timer clock source can be configured to come
from the internal system clock divided by 4 or from an
external clock on shared pin PA2/TMR.
Configuring the Timer/Event Counter Input Clock
Source
The timer clock source can originate from either the sys-
tem clock divided by 4 or from an external clock source.
The system clock divided by 4 is used when the timer is
in the timer mode or in the pulse width measurement
mode.
An external clock source is used when the timer is in the
event counting mode, the clock source being provided
on shared pin PA2/TMR. Depending upon the condition
Rev. 1.10
Read/Write Timing
18
of the TE bit, each high to low, or low to high transition
on the PA2/TMR pin will increment the counter by one.
Timer Registers - TMRH, TMRL
The TMRH and TMRL registers are two 8-bit special
function register locations within the special purpose
Data Memory where the actual timer value is stored.
The value in the timer registers increases by one each
time an internal clock pulse is received or an external
transition occurs on the PA2/TMR pin. The timer will
count from the initial value loaded by the preload regis-
ter to the full count value of FFFFH at which point the
timer overflows and an internal interrupt signal gener-
ated. The timer value will then be reset with the initial
preload register value and continue counting. For a
maximum full range count of 0000H to FFFFH the
preload registers must first be cleared to 0000H. It
should be noted that after power-on the preload regis-
ters will be in an unknown condition. Note that if the
Timer/Event Counter is not running and data is written to
its 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 registers during this period will remain in the
preload registers and will only be written into the actual
counter the next time an overflow occurs.
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,
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, is executed. On the other hand, using instruc-
tions to preload data into the high byte timer register will
result in the data being directly written to the high byte
register. 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
from its associated 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 di-
rectly will only result in reading the previously latched
contents of the low byte buffer and not the actual con-
tents of the low byte timer register.
Timer Control Register - TMRC
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 the Timer Control Register TMRC. To-
gether with the TMRL and TMRH registers, these three
HT82M75R/HT82M75RE
HT82K75R/HT82K75RE
June 11, 2010

Related parts for ht82m75r