English
Language : 

HT45F12_12 Datasheet, PDF (56/103 Pages) Holtek Semiconductor Inc – 8-Bit Flash MCU with Op Amps & Comparators
HT45F12
8-Bit Flash MCU with Op Amps & Comparators
Programming Considerations
Within the user program, one of the first things to consider is port initialisation. After a reset, all of
the I/O data and port control registers 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
selections have been chosen. If the port control registers, PAC~PCC, are then programmed to setup
some pins as outputs, these output pins will have an initial high output value unless the associated
port data registers, PA~PC, are first programmed. Selecting which pins are inputs and which are
outputs can be achieved byte-wide by loading the correct values into the appropriate 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 entire port, modify it to
the required new bit values and then rewrite this data back to the output ports.
S y s te m C lo c k
T1
T2
T3
T4
T1
T2
T3
T4
P o rt D a ta
R e a d fro m P o rt
W r ite to P o r t
Read Modify Write Timing
Port A has the additional capability of providing wake-up functions. When the device is in the
SLEEP or IDLE Mode, various methods are available to wake the device up. One of these is a high
to low transition of any of the Port A pins. Single or multiple pins on Port A can be setup to have this
function. In addition, the Port B pins also provide Open Drain I/O structure options which can be
controlled by the specific register.
Timer/Event Counter
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 a sigle count-up timer of 8-bit capacity.
As the timer has three different operating modes, it can be configured to operate as a general timer,
an external event counter or as a pulse width capture device. The provision of an internal prescaler
to the clock circuitry on giving added range to the timer.
There are two types of registers related to the Timer/Event Counter. The first is the registers that
contain the actual value of the Timer/Event Counter and into which an initial value can be preloaded.
Reading from these registers 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. The Timer/Event Counter can have its clock configured
to come from an internal clock source. In addition, its clock source can also be configured to come
from an external timer pin.
TP S C 2~TP S C 0
TM 1 TM 0
(1 /1 ~ 1 /1 2 8 )
fS Y S
7 - s ta g e P r e s c a le r
TM R
F ilte r
M
F ilte r O n /O ff
C o n fig u r a tio n o p tio n
U
X TE
C o m p a ra to r 1
o u tp u t T M 0 , T M 1
T im e r /E v e n t C o u n te r
M o d e C o n tro l
TO N
P r e lo a d R e g is te r
D a ta B u s
R e lo a d
T im e r /E v e n t
C o u n te r
8 - B it T im e r /E v e n t C o u n te r ¸ 2
O v e r flo w
to In te rru p t
PFD 0
8-bit Timer/Event Counter Structure
2., 
2.,
2 ) # , = J=
Note: The output is controlled by PA5 data.
Rev. 1.20
56
February 27, 2013