English
Language : 

HT82A520R_10 Datasheet, PDF (17/72 Pages) Holtek Semiconductor Inc – Full Speed USB 8-Bit OTP MCU with SPI
· A/D inputs - HT82A620R
This device has 16 A/D converter inputs depending
upon which package type is chosen. All of these ana-
log inputs are pin-shared with I/O pins on Port B and
Port C. If these pins are to be used as A/D inputs and
not as normal I/O pins then the corresponding bits in
the A/D Converter Control Register, ACSR, must be
properly set. There are no configuration options asso-
ciated with the A/D function. If used as I/O pins, then
full pull-high resistor configuration options remain,
however if used as A/D inputs then any pull-high resis-
tor options associated with these pins will be automat-
ically disconnected.
I/O Pin Structures
The vast range of I/O functions and pin-shared options
results in a huge variety of I/O pin structure types. For
this reason the generic Input/Output Port diagram pro-
vided here is for general reference only. As the exact
logical construction of the I/O pin will differ from the
drawing, they are supplied as a guide only to assist with
the functional understanding of the basic I/O pins.
Programming Considerations
Within the user program, one of the first things to con-
sider is port initialisation. After a reset, all of the data and
port control register will be set high. This means that all
I/O pins will default to an input state, the level of which
depends on the other connected circuitry and whether
pull-high options have been selected. If the PAC, PBC,
PCC port control register, are then programmed to setup
some pins as outputs, these output pins will have an ini-
tial high output value unless the associated PA, PB, PC
port 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 register 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 en-
tire port, modify it to the required new bit values and then
rewrite this data back to the output ports.
The ports 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 transition of any
of the port pins. Single or multiple pins on the ports can
be setup to have this function.
S y s te m C lo c k
P o rt D a ta
T1
T2
T3
T4
T1
T2
T3
T4
W r ite to P o r t
R e a d fro m P o rt
Read/Write Timing
HT82A520R/HT82A620R
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. This device contains a single
count-up timer of 16-bit capacity. As each timer has
three different operating modes, they can be configured
to operate as a general timer, an external event counter
or as a pulse width measurement device.
There are two types of registers related to the
Timer/Event Counters. The first is the register that con-
tain the actual value of the Timer/Event Counter and into
which an initial value can be preloaded, and is known as
TMRH, TMRL. Reading from this register retrieves the
contents of the Timer/Event Counter. The second type
of associated register is the Timer Control Register,
which defines the timer options and determines how the
Timer/Event Counter is to be used, and has the name
TMRC. This device can have the timer clocks config-
ured to come from the internal clock sources. In addi-
tion, the timer clock sources can also be configured to
come from the external timer pins.
The external clock source is used when the Timer/Event
Counter is in the event counting mode, the clock source
being provided on the external timer pin. The external
timer pin has the name TMR. Depending upon the con-
dition of the TE bit in the Timer Control Register, each
high to low, or low to high transition on the external timer
input pin will increment the Timer/Event Counter by one.
Configuring the Timer/Event Counter Input Clock
Source
The Timer/Event Counter¢s clock can originate from vari-
ous sources. The instruction clock source (system clock
source divided by 4) is used when the Timer/Event Coun-
ter is in the timer mode or in the pulse width measure-
ment mode. The external clock source is used when the
Timer/Event Counter is in the event counting mode, the
clock source being provided on the external timer pin,
TMR. Depending upon the condition of the TE bit, each
high to low, or low to high transition on the external timer
pin will increment the counter by one.
Timer Registers - TMRL, TMRH
The timer registers are special function registers located
in the Special Purpose RAM Data Memory and are the
places where the actual timer values are stored. The
timer registers are known as TMRL and TMRH. The
value in the timer registers increases by one each time
an internal clock pulse is received or an external transi-
tion occurs on the external timer pin. The timer will count
from the initial value loaded by the preload register to
the full count of FFFFH for the 16-bit timer at which point
the timer overflows and an internal interrupt signal is
generated. The timer value will then be reset with the ini-
tial preload register value and continue counting.
Rev.1.20
17
June 23, 2010