Rev. 1.10
58
November 04, 2019
Rev. 1.10
59
November 04, 2019
HT45F5Q-3
Battery Charger Flash MCU
HT45F5Q-3
Battery Charger Flash MCU
READ PORT Function
Disabled
Enabled
Port Control Register Bit – PxC.n
1
0
1
0
I/O Function
Pin value
Data latch
value
Pin value
Digital Input Function
Digital Output Function (except USIM)
0
USIM: SCK/SCL, SDI/SDA/RX/TX
Pin value
Analog Function
0
Note: The value on the above table is the content of the ACC register after “mov a, Px” instruction is
executed where “x” means the relevant port name.
The additional function of the READ PORT mode is to check the A/D path. When the READ PORT
function is disabled, the A/D path from the external pin to the internal analog input will be switched
off if the A/D input pin function is not selected by the corresponding selection bits. For the MCU
with A/D converter channels, such as A/D AN9~AN0, the desired A/D channel can be switched on
by properly configuring the external analog input channel selection bits in the A/D Control Register
together with the corresponding analog input pin function is selected. However, the additional
function of the READ PORT mode is to force the A/D path to be switched on. For example, when
the AN0 is selected as the analog input channel as the READ PORT function is enabled, the AN0
analog input path will be switched on even if the AN0 analog input pin function is not selected. In
this way, the AN0 analog input path can be examined by internally connecting the digital output on
this shared pin with the AN0 analog input pin switch and then converting the corresponding digital
data without any external analog input voltage connected.
READ PORT function enabled,
AN0 Pin-shared path switched
on automatically
External analog input
channel selection
A/D Converter
AN0
AN9
Digital Output
Function
A/D Channel Input Path Internally Connection
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 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 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.
Port A has the additional capability of providing wake-up function. 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.