Rev. 1.00
5�
��ne ��� �01�
Rev. 1.00
53
��ne ��� �01�
HT66FM5440
Brushless DC Motor A/D Flash MCU
HT66FM5440
Brushless DC Motor A/D Flash MCU
I/O Port Control Registers
Each I/O port has its own control register known as PAC~PDC, to control the input/output
configuration. With this control register, each CMOS output or input can be reconfigured
dynamically under software control. Each pin of the I/O ports is directly mapped to a bit in its
associated port control register. For the I/O pin to function as an input, the corresponding bit of the
control register must be written as a "1". This will then allow the logic state of the input pin to be
directly read by instructions. When the corresponding bit of the control register is written as a "0",
the I/O pin will be setup as a CMOS output. If the pin is currently setup as an output, instructions
can still be used to read the output register. However, it should be noted that the program will in fact
only read the status of the output data latch and not the actual logic status of the output pin.
PxC Register
Bit
7
6
5
4
3
2
1
0
Name
PxC�
PxC6
PxC5
PxC4
PxC3
PxC�
PxC1
PxC0
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
POR
1
1
1
1
1
1
1
1
PxCn
: I/O Port x Pin type selection
0: Output
1: Input
The PxCn bit is used to control the pin type selection. Here the "x"can be A, B, C and D. However,
the actual available bits for each I/O Port may be different.
Pin-shared Functions
The flexibility of the microcontroller range is greatly enhanced by the use of pins that have more
than one function. Limited numbers of pins can force serious design constraints on designers but by
supplying pins with multi-functions, many of these difficulties can be overcome. For these pins, the
desired function of the multi-function I/O pins is selected by a series of registers via the application
program control.
Pin-shared Function Selection Registers
The limited number of supplied pins in a package can impose restrictions on the amount of functions
a certain device can contain. However by allowing the same pins to share several different functions
and providing a means of function selection, a wide range of different functions can be incorporated
into even relatively small package sizes. The device includes Port "x" output function selection
register "n", labeled as PxPSn, and input function selection register, labeled as PRM, which can
select the desired functions of the multi-function pin-shared pins.
When the pin-shared input function is selected to be used, the copprsponding input and output
functions selection should be properly managed. For example, if the I
2
C SDA line is used, the
corresponding output pin-shared function should be configured as the SDA function by configuring
the PxPSn register and the SDA signal input should be properly selected using the PRM register.
Note that the UART TX output pin function must also be properly configured using the PxPSn and
PRM registers. If the external interrupt function is selected to be used, the relevant output pin-shared
function should be selected as an I/O function and the interrupt input signal should be selected.
The most important point to note is to make sure that the desired pin-shared function is properly
selected and also deselected. For most pin-shared functions, to select the desired pin-shared function,
the pin-shared function should first be correctly selected using the corresponding pin-shared control
register. After that the corresponding peripheral functional setting should be configured and then
the peripheral function can be enabled. However, a special point must be noted for some digital