![CMOSTEK CMT2189C Скачать руководство пользователя страница 65](http://html1.mh-extra.com/html/cmostek/cmt2189c/cmt2189c_user-manualline_2627489065.webp)
AN202
V1.0 | Page 65/73
www.cmostek.com
16 I/O Port
There are 16 GPIO portsin the chip. But limited to the packagesize, only 6 IO ports of PORTA[2:0], PORTA5,
PORTC2 and PORTC4 have the package terminals, and the othersare inside the chip and have no the
package terminals.In addition to being an ordinary input / output port, these IO ports usually have some
functions to communicate with the kernel peripheral circuits, see the following in details.
16.1
PORTA Port and TRISA Register
PORTA is an 8-bit bi-directional port.The corresponding data direction register is TRISA. However, it is
important to note that the fifth bit is not used here because PORTA<5> is a single input directional port.Setting
a certain bit to "1" in the TRISA register will set the corresponding PORTA port as the input port (at this time,
the output driver will be turned off). Conversely, setting a certain bit to "0" will set the corresponding PORTA
port as the output port.When configurated as the output port, the output drive circuit is opened and the data in
the output register will be sent to the output port.When reading the PORTA, the PORTA content will reflect the
status of the input port.When writing the PORTA, the PORTA content will be written to the output register.All
operations follow the "read-modify-write
” micro process, namely the data is read, and then is modified, and
then is written to the output register.When MCLRE is 1, the value read from PORTA<5> is 0, which is as the
external reset pin at this time.
16.2
Other Functions of the Port
Each port of the PORTA has a status change interrupt option and a weak pull-up option.
16.2.1
Weak Pull-Up
Each port of the PORTA (except for PORTA<5>) has an internal weak pull-up function that can be set
individually. Controlling the bit of the WPUAx register can enable or turn off the weak pull-up circuit.When the
GPIO is set as output, these weak pull-up circuits are automatically turned off.The weak pull-up circuit can be
turned off during the power-upreset period.This is determined by the /PAPU bit of the OPTION register.There
is also a weak pull-up function inside PORTA<5>. The weak pull-up function will be automatically enabled
when the PORTA<5> is set as /MCLR. When the PORTA<5> is set as GPIO, the weak pull-up circuit will be
automatically turned off.
16.2.2
Interrupt-On-Change
Each port of the PORTA can be separately set as an interrupt source (interrupt-on-change).Controlling the
bitof the IOCAx register can enable or turn off the interrupts of these ports. The interrupt-on-change is invalid
on Power-on Reset.
When enabling the interrupt-on-change function, the current port level value is compared to the old value of
Содержание CMT2189C
Страница 32: ...AN202 V1 0 Page 32 73 www cmostek com...