Datasheet

Digital I/O Introduction
www.ti.com
8.1 Digital I/O Introduction
MSP430 devices have up to eight digital I/O ports implemented, P1 to P8. Each port has up to eight I/O
pins. Every I/O pin is individually configurable for input or output direction, and each I/O line can be
individually read or written to.
Ports P1 and P2 have interrupt capability. Each interrupt for the P1 and P2 I/O lines can be individually
enabled and configured to provide an interrupt on a rising edge or falling edge of an input signal. All P1
I/O lines source a single interrupt vector, and all P2 I/O lines source a different, single interrupt vector.
The digital I/O features include:
Independently programmable individual I/Os
Any combination of input or output
Individually configurable P1 and P2 interrupts
Independent input and output data registers
Individually configurable pullup or pulldown resistors
Individually configurable pin-oscillator function (some MSP430 devices)
NOTE: MSP430G22x0 : These devices feature digital I/O pins P1.2, P1.5, P1.6 and P1.7. The
GPIOs P1.0, P1.1, P1.3, P1.4, P2.6, and P2.7 are implemented on this device but not
available on the device pin-out. To avoid floating inputs, these GPIOs, these digital I/Os
should be properly initialized by running a start-up code. See initialization code below:
mov.b #0x1B, P1REN; ; Terminate unavailable Port1 pins properly ; Config as Input with pull-
down enabled
xor.b #0x20, BCSCTL3; ; Select VLO as low freq clock
The initialization code configures GPIOs P1.0, P1.1, P1.3, and P1.4 as inputs with pull-down
resistor enabled (that is, P1REN.x = 1) and GPIOs P2.6 and P2.7 are terminated by
selecting VLOCLK as ACLK – see the Basic Clock System chapter for details. The register
bits of P1.0, P1.1, P1.3, and P1.4 in registers P1OUT, P1DIR, P1IFG, P1IE, P1IES, P1SEL
and P1REN should not be altered after the initialization code is executed. Also, all Port2
registers are should not be altered.
8.2 Digital I/O Operation
The digital I/O is configured with user software. The setup and operation of the digital I/O is discussed in
the following sections.
8.2.1 Input Register PxIN
Each bit in each PxIN register reflects the value of the input signal at the corresponding I/O pin when the
pin is configured as I/O function.
Bit = 0: The input is low
Bit = 1: The input is high
NOTE: Writing to Read-Only Registers PxIN
Writing to these read-only registers results in increased current consumption while the write
attempt is active.
8.2.2 Output Registers PxOUT
Each bit in each PxOUT register is the value to be output on the corresponding I/O pin when the pin is
configured as I/O function, output direction, and the pullup/down resistor is disabled.
Bit = 0: The output is low
Bit = 1: The output is high
328
Digital I/O SLAU144JDecember 2004Revised July 2013
Submit Documentation Feedback
Copyright © 2004–2013, Texas Instruments Incorporated