HT46R068B/HT46R069B
Enhanced A/D Type 8-bit OTP MCU
Programming Considerations
Within the user program, one of the first things to consider is port initialisation. After a reset, the
I/O data register and I/O 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 port control registers, are then programmed to setup
some pins as outputs, these output pins will have an initial high output value unless the associated
port data register is 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 entire port, modify it to the required new bit
values and then rewrite this data back to the output ports.
T
1
T
2
T
3
T
4
T
1
T
2
T
3
T
4
y
e
s
t
m
C
l
c
o
k
P
r
o
t
D
a
a
t
R
e
a
f
o
d
r
m
P
o
t
r
W
i
r
e
t
t
o
P
o
t
r
Read Modify Write Timing
Pins PA0 to PA7 each have a wake-up functions, selected via the PAWK register. When the device
is in the Idle/Sleep Mode, various methods are available to wake the device up. One of these is a
high to low transition of any of the these pins. Single or multiple pins on Port A can be setup to
have this function.
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 devices contain two 8-bit and one 16-bit timer. As the
timers have three different operating modes, they 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 gives added range to the timers.
There are two types of registers related to the Timer/Event Counters. The first is the register that
contains the actual value of the timer and into which an initial value can be preloaded. 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 is to
be used. The device can have the timer clock configured to come from the internal clock source. In
addition, the timer clock source can also be configured to come from an external timer pin.
Configuring the Timer/Event Counter Input Clock Source
The Timer/Event Counter clock source can originate from various sources, an internal clock or an
external pin. The internal clock source is used when the timer is in the timer mode or in the pulse
width capture mode. For some Timer/Event Counters, this internal clock source is first divided by a
prescaler, the division ratio of which is conditioned by the Timer Control Register bits. An external
clock source is used when the timer is in the event counting mode, the clock source being provided
on an external timer pin TCn. Depending upon the condition of the TnEG bit, each high to low, or
low to high transition on the external timer pin will increment the counter by one.
Rev. 1.00
47
�anꢀaꢁꢂ ꢃꢄꢅ ꢃ011