Programming Considerations
Within the user program, one of the first things to consider is port initialization. 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 op-
tions have been selected. If the port control registers, PAC, PBC, PCC, etc., are then programmed
to setup some pins as outputs, these output pins will have an initial high output value unless the as-
sociated port data registers, PA, PB, PC, etc., are first programmed. Selecting which pins are in-
puts 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 en-
tire port, modify it to the required new bit values and then rewrite this data back to the output ports.
Port A has the additional capability of providing wake-up functions. When the chip is in the HALT
state, 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.
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 in the A/D Type MCU series contain either one
or two count up timers of either 8 or 16-bit capacity depending upon which device is selected. 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. With the exception of
TMR1 in the HT46R24/HT46C24 devices, the provision of an internal 8-stage prescaler to the
timer clock circuitry gives added range to the timer.
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 associ-
ated register is the timer control register which defines the timer options and determines how the
timer is to be used. All devices can have the timer clock configured to come from the internal clock
source. In addition, with the exception of TMR0 in the 28-pin package in the HT46R24/HT46C24
devices, the timer clock source can also be configured to come from an external timer pin. The ac-
companying table lists the associated timer register names.
34
A/D Type MCU
T 1
T 2
T 3
T 4
T 1
T 2
T 3
T 4
W r i t e t o p o r t
R e a d f r o m p o r t
S y s t e m C l o c k
P o r t D a t a
Содержание HT46R22
Страница 7: ...vi A D Type MCU...
Страница 9: ...viii A D Type MCU...
Страница 10: ...P a r t I Microcontroller Profile Part I Microcontroller Profile 1...
Страница 11: ...2 A D Type MCU...
Страница 90: ...P a r t I I Programming Language Part II Programming Language 81...
Страница 91: ...82 A D Type MCU...
Страница 97: ...88 A D Type MCU...
Страница 128: ...P a r t I I I Development Tools Part III Development Tools 119...
Страница 129: ...120 A D Type MCU...
Страница 140: ...Appendix Appendix 131...
Страница 141: ...132 A D Type MCU...
Страница 151: ...142 A D Type MCU...
Страница 152: ...A p p e n d i x B Package Information Appendix B Package Information 143 B...
Страница 161: ...A D Type MCU...
Страница 162: ...Amendments...