
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 and PCC, 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 and 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 appropri-
ate 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. Each device contains an internal 8-bit count-up timer. With
three operating modes, the timers can be configured to operate as a general timer, external event
counter or as a pulse width measurement device. The provision of an internal 8-stage prescaler to
the timer clock circuitry gives added range to the timer.
There are two registers related to the Timer/Event Counter, TMR and TMRC. The TMR register is
the register that contains the actual timing value. Writing to TMR places an initial starting value in
the Timer/Event Counter preload register while reading TMR retrieves the contents of the
Timer/Event Counter. The TMRC 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 config-
ured to come from the internal clock source or from an external clock on shared pin PC1/TMR.
Configuring the Timer/Event Counter Input Clock Source
The internal timer
¢
s clock source can originate from either the system clock or from an external
clock source. The system clock input timer source is used when the timer is in the timer mode or in
the pulse width measurement mode. The internal timer clock also passes through a prescaler, the
value of which is conditioned by the bits PSC0, PSC1 and PSC2.
26
Cost-Effective I/O 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
Содержание HT48R05A-1
Страница 7: ...vi Cost Effective I O Type MCU...
Страница 8: ...P a r t I Microcontroller Profile Part I Microcontroller Profile 1...
Страница 9: ...2 Cost Effective I O Type MCU...
Страница 52: ...P a r t I I Programming Language Part II Programming Language 45...
Страница 53: ...46 Cost Effective I O Type MCU...
Страница 59: ...52 Cost Effective I O Type MCU...
Страница 90: ...P a r t I I I Development Tools Part III Development Tools 83...
Страница 91: ...84 Cost Effective I O Type MCU...
Страница 101: ...94 Cost Effective I O Type MCU...
Страница 104: ...Appendix Appendix 97...
Страница 105: ...98 Cost Effective I O Type MCU...
Страница 115: ...108 Cost Effective I O Type MCU...
Страница 116: ...A p p e n d i x B Package Information Appendix B Package Information 109 B...
Страница 123: ...116 Cost Effective I O Type MCU...
Страница 125: ...Amendments...