Chapter 7I/O PortPorts VII - 337.3.2 Description (Port 2)■ General Port SetupEach bit can be set individually as either an input or output by the port 2 I/O control register (P2DIR). The controlflag of the P2DIR register is set to “1” for output mode, and to “0” for input mode.To read input data of a pin, set the control flag of the P2DIR register to “0” and read the value of the port 2 inputregister (P2IN).To output data to a pin, set the control flag of the P2DIR register to “1” and write data to the port 2 output register(P2OUT).Each bit can be set individually if pull-up resistor is added or not, by the port 2 pull-up control register (P2PLU).Set the control flag of the P2PLU register to “1” to add pull-up resistor.■ Special Function Pin SetupP20 to P21 are used as serial 2 I/O pins as well. P20 is an I/O pin for the serial 2 clock. When the SC2SBTS flagof the serial interface 2 mode register 1 (SC2CTR1) and the P20M flag of the port 2 output mode register (P2MD)are set to “1”, P20 becomes an I/O pin for serial clock. P21 is an input pin for the serial 2 and UART 2 receptiondata. When the SC2SBIS flag of the SC2CTR1 register is set to “1” , P21 becomes an input pin for the serial data.P22 to P24 are used as serial 1 I/O pins as well. P22 is an output pin for the serial 1 and UART 1 transmissiondata. When the P22M flag of the P2MD register is set to “1”, P22 becomes an output pin for the serial data. Whenthe P22M flag of the P2MD register is set to “1”, P23 becomes an I/O pin for serial clock. P24 is an input pin forthe serial 1 and UART 1 reception data.P25 to P27 are used as serial 0 I/O pins as well. P25 is an output pin for the serial 0 and UART 0 transmissiondata. When the 25M flag of the P2MD register is set to “1”, P25 becomes an output pin for the serial data. Whenthe P26 flag of the P2MD register is set to “1”, P26 becomes an I/O pin for serial clock. P27 is an input pin for theserial 0 and UART 0 reception data.