8.1 digital i/o introduction - university of...

32
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 336 Digital I/O SLAU144I ± December 2004 ± Revised January 2012 Submit Documentation Feedback Copyright 2004±2012, Texas Instruments Incorporated

Upload: others

Post on 24-May-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 8.1 Digital I/O Introduction - University Of Illinoiscoecsl.ece.illinois.edu/me461/Lectures/DigitalIOUserguide.pdf1/2/4/8 DV SS DV CC TAxCLK 1 0 1 TASSELx 3 2 1 0 ID.x 16-bit Timer

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/Opins. Every I/O pin is individually configurable for input or output direction, and each I/O line can beindividually read or written to.

Ports P1 and P2 have interrupt capability. Each interrupt for the P1 and P2 I/O lines can be individuallyenabled and configured to provide an interrupt on a rising edge or falling edge of an input signal. All P1I/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. TheGPIOs P1.0, P1.1, P1.3, P1.4, P2.6, and P2.7 are implemented on this device but notavailable on the device pin-out. To avoid floating inputs, these GPIOs, these digital I/Osshould 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 withpull-down enabledxor.b #0x20, BCSCTL3; ; Select VLO as low freq clockThe initialization code configures GPIOs P1.0, P1.1, P1.3, and P1.4 as inputs with pull-downresistor enabled (that is, P1REN.x = 1) and GPIOs P2.6 and P2.7 are terminated byselecting VLOCLK as ACLK see the Basic Clock System chapter for details. The registerbits of P1.0, P1.1, P1.3, and P1.4 in registers P1OUT, P1DIR, P1IFG, P1IE, P1IES, P1SELand P1REN should not be altered after the initialization code is executed. Also, all Port2registers 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 inthe 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 thepin is configured as I/O function.

Bit = 0: The input is lowBit = 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 writeattempt 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 isconfigured as I/O function, output direction, and the pullup/down resistor is disabled.

Bit = 0: The output is lowBit = 1: The output is high

336 Digital I/O SLAU144I December 2004 Revised January 2012Submit Documentation Feedback

Copyright 2004 2012, Texas Instruments Incorporated

Page 2: 8.1 Digital I/O Introduction - University Of Illinoiscoecsl.ece.illinois.edu/me461/Lectures/DigitalIOUserguide.pdf1/2/4/8 DV SS DV CC TAxCLK 1 0 1 TASSELx 3 2 1 0 ID.x 16-bit Timer

www.ti.com Digital I/O Operation

If the pin's pullup/pulldown resistor is enabled, the corresponding bit in the PxOUT register selects pullupor pulldown.

Bit = 0: The pin is pulled downBit = 1: The pin is pulled up

8.2.3 Direction Registers PxDIR

Each bit in each PxDIR register selects the direction of the corresponding I/O pin, regardless of theselected function for the pin. PxDIR bits for I/O pins that are selected for other functions must be set asrequired by the other function.

Bit = 0: The port pin is switched to input directionBit = 1: The port pin is switched to output direction

8.2.4 Pullup/Pulldown Resistor Enable Registers PxREN

Each bit in each PxREN register enables or disables the pullup/pulldown resistor of the corresponding I/Opin. The corresponding bit in the PxOUT register selects if the pin is pulled up or pulled down.

Bit = 0: Pullup/pulldown resistor disabledBit = 1: Pullup/pulldown resistor enabled

8.2.5 Function Select Registers PxSEL and PxSEL2

Port pins are often multiplexed with other peripheral module functions. See the device-specific data sheetto determine pin functions. Each PxSEL and PxSEL2 bit is used to select the pin function - I/O port orperipheral module function.

Table 8-1. PxSEL and PxSEL2

PxSEL2 PxSEL Pin Function

0 0 I/O function is selected.

0 1 Primary peripheral module function is selected.

1 0 Reserved. See device-specific data sheet.

1 1 Secondary peripheral module function is selected.

Setting PxSELx = 1 does not automatically set the pin direction. Other peripheral module functions mayrequire the PxDIRx bits to be configured according to the direction needed for the module function. Seethe pin schematics in the device-specific data sheet.

NOTE: Setting PxREN = 1 When PxSEL = 1

On some I/O ports on the MSP430F261x and MSP430F2416/7/8/9, enabling thepullup/pulldown resistor (PxREN = 1) while the module function is selected (PxSEL = 1) doesnot disable the logic output driver. This combination is not recommended and may result inunwanted current flow through the internal resistor. See the device-specific data sheet pinschematics for more information.

;Output ACLK on P2.0 on MSP430F21x1BIS.B #01h,&P2SEL ; Select ACLK function for pinBIS.B #01h,&P2DIR ; Set direction to output *Required*

NOTE: P1 and P2 Interrupts Are Disabled When PxSEL = 1

When any P1SELx or P2SELx bit is set, the corresponding pin's interrupt function isdisabled. Therefore, signals on these pins will not generate P1 or P2 interrupts, regardless ofthe state of the corresponding P1IE or P2IE bit.

337SLAU144I December 2004 Revised January 2012 Digital I/OSubmit Documentation Feedback

Copyright 2004 2012, Texas Instruments Incorporated

Page 3: 8.1 Digital I/O Introduction - University Of Illinoiscoecsl.ece.illinois.edu/me461/Lectures/DigitalIOUserguide.pdf1/2/4/8 DV SS DV CC TAxCLK 1 0 1 TASSELx 3 2 1 0 ID.x 16-bit Timer

Divider

1/2/4/8

DVSS

DVCC

TAxCLK

1

0

1

TASSELx

3

2

1

0

ID.x

16-bit TimerTAR

Capture RegisterCCRx

Part of Digital I/OPx.y

Part of Timer_A

PAD

Digital I/O Operation www.ti.com

When a port pin is selected as an input to a peripheral, the input signal to the peripheral is a latchedrepresentation of the signal at the device pin. While PxSELx = 1, the internal input signal follows the signalat the pin. However, if the PxSELx = 0, the input to the peripheral maintains the value of the input signal atthe device pin before the PxSELx bit was reset.

8.2.6 Pin Oscillator

Some MSP430 devices have a pin oscillator function built-in to some pins. The pin oscillator function maybe used in capacitive touch sensing applications to eliminate external passive components. Additionally,the pin oscillator may be used in sensor applications.

No external components to create the oscillationCapacitive sensors can be connected directly to MSP430 pinRobust, typical built-in hysteresis of ~0.7 V

When the pin oscillator function is enabled, other pin configurations are overwritten. The output driver isturned off while the weak pullup/pulldown is enabled and controlled by the voltage level on the pin itself.The voltage on the I/O is fed into the Schmitt trigger of the pin and then routed to a timer. The connectionto the timer is device specific and, thus, defined in the device-specific data sheet. The Schmitt-triggeroutput is inverted and then decides if the pullup or the pulldown is enabled. Due to the inversion, the pinstarts to oscillate as soon as the pin oscillator pin configuration is selected. Some of the pin-oscillatoroutputs are combined by a logical OR before routing to a timer clock input or timer capture channel.Therefore, only one pin oscillator should be enabled at a time. The oscillation frequency of each pin isdefined by the load on the pin and by the I/O type. I/Os with analog functions typically show a loweroscillation frequency than pure digital I/Os. See the device-specific data sheet for details. Pins withoutexternal load show typical oscillation frequencies of 1 MHz to 3 MHz.

Pin oscillator in a cap touch application

A typical touch pad application using the pin oscilator is shown in Figure 8-1.

Figure 8-1. Example Circuitry and Configuration using the Pin Oscillator

A change of the capacitance of the touch pad (external capacitive load) has an effect on the pin oscillatorfrequency. An approaching finger tip increases the capacitance of the touch pad thus leads to a lowerself-oscillation frequency due to the longer charging time. The oscillation frequency can directly becaptured in a built-in Timer channel. The typical sensitivity of a pin is shown in Figure 8-2.

338 Digital I/O SLAU144I December 2004 Revised January 2012Submit Documentation Feedback

Copyright 2004 2012, Texas Instruments Incorporated

Page 4: 8.1 Digital I/O Introduction - University Of Illinoiscoecsl.ece.illinois.edu/me461/Lectures/DigitalIOUserguide.pdf1/2/4/8 DV SS DV CC TAxCLK 1 0 1 TASSELx 3 2 1 0 ID.x 16-bit Timer

CLOAD − External Capacitance − pF

Fosc

−Typic

al O

scilla

tion F

requency

−M

Hz

−T

0.00

0.15

0.30

0.45

0.60

0.75

0.90

1.05

1.20

1.35

1.50

10 50 100

VCC = 3.0 V

www.ti.com Digital I/O Operation

Figure 8-2. Typical Pin-Oscillation Frequency

8.2.7 P1 and P2 Interrupts

Each pin in ports P1 and P2 have interrupt capability, configured with the PxIFG, PxIE, and PxIESregisters. All P1 pins source a single interrupt vector, and all P2 pins source a different single interruptvector. The PxIFG register can be tested to determine the source of a P1 or P2 interrupt.

8.2.7.1 Interrupt Flag Registers P1IFG, P2IFG

Each PxIFGx bit is the interrupt flag for its corresponding I/O pin and is set when the selected input signaledge occurs at the pin. All PxIFGx interrupt flags request an interrupt when their corresponding PxIE bitand the GIE bit are set. Each PxIFG flag must be reset with software. Software can also set each PxIFGflag, providing a way to generate a software initiated interrupt.

Bit = 0: No interrupt is pendingBit = 1: An interrupt is pending

Only transitions, not static levels, cause interrupts. If any PxIFGx flag becomes set during a Px interruptservice routine, or is set after the RETI instruction of a Px interrupt service routine is executed, the setPxIFGx flag generates another interrupt. This ensures that each transition is acknowledged.

NOTE: PxIFG Flags When Changing PxOUT or PxDIR

Writing to P1OUT, P1DIR, P2OUT, or P2DIR can result in setting the corresponding P1IFGor P2IFG flags.

8.2.7.2 Interrupt Edge Select Registers P1IES, P2IES

Each PxIES bit selects the interrupt edge for the corresponding I/O pin.Bit = 0: The PxIFGx flag is set with a low-to-high transitionBit = 1: The PxIFGx flag is set with a high-to-low transition

339SLAU144I December 2004 Revised January 2012 Digital I/OSubmit Documentation Feedback

Copyright 2004 2012, Texas Instruments Incorporated

Page 5: 8.1 Digital I/O Introduction - University Of Illinoiscoecsl.ece.illinois.edu/me461/Lectures/DigitalIOUserguide.pdf1/2/4/8 DV SS DV CC TAxCLK 1 0 1 TASSELx 3 2 1 0 ID.x 16-bit Timer

Digital I/O Operation www.ti.com

NOTE: Writing to PxIESx

Writing to P1IES, or P2IES can result in setting the corresponding interrupt flags.

PxIESx PxINx PxIFGx

0 1 0 May be set

0 1 1 Unchanged

1 0 0 Unchanged

1 0 1 May be set

8.2.7.3 Interrupt Enable P1IE, P2IE

Each PxIE bit enables the associated PxIFG interrupt flag.Bit = 0: The interrupt is disabled.Bit = 1: The interrupt is enabled.

8.2.8 Configuring Unused Port Pins

Unused I/O pins should be configured as I/O function, output direction, and left unconnected on the PCboard, to prevent a floating input and reduce power consumption. The value of the PxOUT bit is irrelevant,since the pin is unconnected. Alternatively, the integrated pullup/pulldown resistor can be enabled bysetting the PxREN bit of the unused pin to prevent the floating input. See the System Resets, Interrupts,and Operating Modes chapter for termination of unused pins.

340 Digital I/O SLAU144I December 2004 Revised January 2012Submit Documentation Feedback

Copyright 2004 2012, Texas Instruments Incorporated

Page 6: 8.1 Digital I/O Introduction - University Of Illinoiscoecsl.ece.illinois.edu/me461/Lectures/DigitalIOUserguide.pdf1/2/4/8 DV SS DV CC TAxCLK 1 0 1 TASSELx 3 2 1 0 ID.x 16-bit Timer

www.ti.com Digital I/O Registers

8.3 Digital I/O Registers

The digital I/O registers are listed in Table 8-2.

Table 8-2. Digital I/O Registers

Port Register Short Form Address Register Type Initial State

Input P1IN 020h Read only -

Output P1OUT 021h Read/write Unchanged

Direction P1DIR 022h Read/write Reset with PUC

Interrupt Flag P1IFG 023h Read/write Reset with PUC

P1 Interrupt Edge Select P1IES 024h Read/write Unchanged

Interrupt Enable P1IE 025h Read/write Reset with PUC

Port Select P1SEL 026h Read/write Reset with PUC

Port Select 2 P1SEL2 041h Read/write Reset with PUC

Resistor Enable P1REN 027h Read/write Reset with PUC

Input P2IN 028h Read only -

Output P2OUT 029h Read/write Unchanged

Direction P2DIR 02Ah Read/write Reset with PUC

Interrupt Flag P2IFG 02Bh Read/write Reset with PUC

P2 Interrupt Edge Select P2IES 02Ch Read/write Unchanged

Interrupt Enable P2IE 02Dh Read/write Reset with PUC

Port Select P2SEL 02Eh Read/write 0C0h with PUC

Port Select 2 P2SEL2 042h Read/write Reset with PUC

Resistor Enable P2REN 02Fh Read/write Reset with PUC

Input P3IN 018h Read only -

Output P3OUT 019h Read/write Unchanged

Direction P3DIR 01Ah Read/write Reset with PUCP3

Port Select P3SEL 01Bh Read/write Reset with PUC

Port Select 2 P3SEL2 043h Read/write Reset with PUC

Resistor Enable P3REN 010h Read/write Reset with PUC

Input P4IN 01Ch Read only -

Output P4OUT 01Dh Read/write Unchanged

Direction P4DIR 01Eh Read/write Reset with PUCP4

Port Select P4SEL 01Fh Read/write Reset with PUC

Port Select 2 P4SEL2 044h Read/write Reset with PUC

Resistor Enable P4REN 011h Read/write Reset with PUC

Input P5IN 030h Read only -

Output P5OUT 031h Read/write Unchanged

Direction P5DIR 032h Read/write Reset with PUCP5

Port Select P5SEL 033h Read/write Reset with PUC

Port Select 2 P5SEL2 045h Read/write Reset with PUC

Resistor Enable P5REN 012h Read/write Reset with PUC

Input P6IN 034h Read only -

Output P6OUT 035h Read/write Unchanged

Direction P6DIR 036h Read/write Reset with PUCP6

Port Select P6SEL 037h Read/write Reset with PUC

Port Select 2 P6SEL2 046h Read/write Reset with PUC

Resistor Enable P6REN 013h Read/write Reset with PUC

341SLAU144I December 2004 Revised January 2012 Digital I/OSubmit Documentation Feedback

Copyright 2004 2012, Texas Instruments Incorporated

Page 7: 8.1 Digital I/O Introduction - University Of Illinoiscoecsl.ece.illinois.edu/me461/Lectures/DigitalIOUserguide.pdf1/2/4/8 DV SS DV CC TAxCLK 1 0 1 TASSELx 3 2 1 0 ID.x 16-bit Timer

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.

7 6 5 4 3 2 1 0 PxIN.7 PxIN.6 PxIN.5 PxIN.4 PxIN.3 PxIN.2 PxIN.1 PxIN.0

R r r r r r r r PxIN.0 Bit 0 0 IF PxDIR.0 = 0 PxIN.0 pin is LOW

1 IF PxDIR.0 = 0 PxIN.0 pin is HIGH PxIN.1 Bit 1 0 IF PxDIR.1 = 0 PxIN.1 pin is LOW

1 IF PxDIR.1 = 0 PxIN.1 pin is HIGH PxIN.2 Bit 2 0 IF PxDIR.2 = 0 PxIN.2 pin is LOW

1 IF PxDIR.2 = 0 PxIN.2 pin is HIGH PxIN.3 Bit 3 0 IF PxDIR.3 = 0 PxIN.3 pin is LOW

1 IF PxDIR.3 = 0 PxIN.3 pin is HIGH PxIN.4 Bit 4 0 IF PxDIR.4 = 0 PxIN.4 pin is LOW

1 IF PxDIR.4 = 0 PxIN.4 pin is HIGH PxIN.5 Bit 5 0 IF PxDIR.5 = 0 PxIN.5 pin is LOW

1 IF PxDIR.5 = 0 PxIN.5 pin is HIGH PxIN.6 Bit 6 0 IF PxDIR.6 = 0 PxIN.6 pin is LOW

1 IF PxDIR.6 = 0 PxIN.6 pin is HIGH PxIN.7 Bit 7 0 IF PxDIR.7 = 0 PxIN.7 pin is LOW

1 IF PxDIR.7 = 0 PxIN.7 pin 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.

Page 8: 8.1 Digital I/O Introduction - University Of Illinoiscoecsl.ece.illinois.edu/me461/Lectures/DigitalIOUserguide.pdf1/2/4/8 DV SS DV CC TAxCLK 1 0 1 TASSELx 3 2 1 0 ID.x 16-bit Timer

8.2.2 Output Registers PxOUT

7 6 5 4 3 2 1 0 PxOUT.7 PxOUT.6 PxOUT.5 PxOUT.4 PxOUT.3 PxOUT.2 PxOUT.1 PxOUT.0

rw (x) rw (x) rw (x) rw (x) rw (x) rw (x) rw (x) rw (x)  

PxOUT.0 Bit 0 If Pin0 configured as I/O function, output direction and its resistor is disabled: 0 Pin0 output Low 1 Pin0 output High If Pin0 configured as I/O function and its resistor is enabled: 0 Pin0 is pulled down 1 Pin0 is pulled up

PxOUT.1 Bit 1 If Pin1 configured as I/O function, output direction and its resistor is disabled: 0 Pin1 output Low 1 Pin1 output High If Pin1 configured as I/O function and its resistor is enabled: 0 Pin1 is pulled down 1 Pin1 is pulled up

PxOUT.2 Bit 2 If Pin2 configured as I/O function, output direction and its resistor is disabled: 0 Pin2 output Low 1 Pin2 output High If Pin2 configured as I/O function and its resistor is enabled: 0 Pin2 is pulled down 1 Pin2 is pulled up

PxOUT.3 Bit 3 If Pin3 configured as I/O function, output direction and its resistor is disabled: 0 Pin3 output Low 1 Pin3 output High If Pin3 configured as I/O function and its resistor is enabled: 0 Pin3 is pulled down 1 Pin3 is pulled up

PxOUT.4 Bit 4 If Pin4 configured as I/O function, output direction and its resistor is disabled: 0 Pin4 output Low 1 Pin4 output High If Pin4 configured as I/O function and its resistor is enabled: 0 Pin4 is pulled down 1 Pin4 is pulled up

PxOUT.5 Bit 5 If Pin5 configured as I/O function, output direction and its resistor is disabled: 0 Pin5 output Low 1 Pin5 output High If Pin5 configured as I/O function and its resistor is enabled: 0 Pin5 is pulled down 1 Pin5 is pulled up

PxOUT.6 Bit 6 If Pin6 configured as I/O function, output direction and its resistor is disabled: 0 Pin6 output Low 1 Pin6 output High If Pin6 configured as I/O function and its resistor is enabled: 0 Pin6 is pulled down 1 Pin6 is pulled up

PxOUT.7 Bit 7 If Pin7 configured as I/O function, output direction and its resistor is disabled: 0 Pin7 output Low 1 Pin7 output High If Pin7 configured as I/O function and its resistor is enabled: 0 Pin7 is pulled down 1 Pin7 is pulled up

Page 9: 8.1 Digital I/O Introduction - University Of Illinoiscoecsl.ece.illinois.edu/me461/Lectures/DigitalIOUserguide.pdf1/2/4/8 DV SS DV CC TAxCLK 1 0 1 TASSELx 3 2 1 0 ID.x 16-bit Timer

8.2.3 Direction Registers PxDIR Each bit in each PxDIR register selects the direction of the corresponding I/O pin, regardless of the selected function for the pin. PxDIR bits for I/O pins that are selected for other functions must be set as required by the other function .

7 6 5 4 3 2 1 0 PxDIR.7 PxDIR.6 PxDIR.5 PxDIR.4 PxDIR.3 PxDIR.2 PxDIR.1 PxDIR.0

rw (0) rw (0) rw (0) rw (0) rw (0) rw (0) rw (0) rw (0)  

PxDIR.0 Bit 0 0 Port Pin0 is switched to input direction 1 Port Pin0 is switched to output direction

PxDIR.1 Bit 1 0 Port Pin1 is switched to input direction 1 Port Pin1 is switched to output direction

PxDIR.2 Bit 2 0 Port Pin2 is switched to input direction 1 Port Pin2 is switched to output direction

PxDIR.3 Bit 3 0 Port Pin3 is switched to input direction 1 Port Pin3 is switched to output direction

PxDIR.4 Bit 4 0 Port Pin4 is switched to input direction 1 Port Pin4 is switched to output direction

PxDIR.5 Bit 5 0 Port Pin5 is switched to input direction 1 Port Pin5 is switched to output direction

PxDIR.6 Bit 6 0 Port Pin6 is switched to input direction 1 Port Pin6 is switched to output direction

PxDIR.7 Bit 7 0 Port Pin7 is switched to input direction 1 Port Pin7 is switched to output direction

8.2.4 Pullup/Pulldown Resistor Enable Registers PxREN Each bit in each PxREN register enables or disables the pullup/pulldown resistor of the corresponding I/O pin. The corresponding bit in the PxOUT register selects if the pin is pulled up or pulled down.

7 6 5 4 3 2 1 0 PxREN.7 PxREN.6 PxREN.5 PxREN.4 PxREN.3 PxREN.2 PxREN.1 PxREN.0

rw (0) rw (0) rw (0) rw (0) rw (0) rw (0) rw (0) rw (0)  

PxREN.0 Bit 0 0 Port Pin0’s Resistor Disabled/Not Connected 1 Port Pin0’s Resistor Enabled, PxOUT.0 determines if it is used as Pullup or Pulldown resistor.

PxREN.1 Bit 1 0 Port Pin1’s Resistor Disabled/Not Connected 1 Port Pin1’s Resistor Enabled, PxOUT.1 determines if it is used as Pullup or Pulldown resistor.

PxREN.2 Bit 2 0 Port Pin2’s Resistor Disabled/Not Connected 1 Port Pin2’s Resistor Enabled, PxOUT.2 determines if it is used as Pullup or Pulldown resistor.

PxREN.3 Bit 3 0 Port Pin3’s Resistor Disabled/Not Connected 1 Port Pin3’s Resistor Enabled, PxOUT.3 determines if it is used as Pullup or Pulldown resistor.

PxREN.4 Bit 4 0 Port Pin4’s Resistor Disabled/Not Connected 1 Port Pin4’s Resistor Enabled, PxOUT.4 determines if it is used as Pullup or Pulldown resistor.

PxREN.5 Bit 5 0 Port Pin5’s Resistor Disabled/Not Connected 1 Port Pin5’s Resistor Enabled, PxOUT.5 determines if it is used as Pullup or Pulldown resistor.

PxREN.6 Bit 6 0 Port Pin6’s Resistor Disabled/Not Connected 1 Port Pin6’s Resistor Enabled, PxOUT.6 determines if it is used as Pullup or Pulldown resistor.

PxREN.7 Bit 7 0 Port Pin7’s Resistor Disabled/Not Connected 1 Port Pin7’s Resistor Enabled, PxOUT.7 determines if it is used as Pullup or Pulldown resistor.

Page 10: 8.1 Digital I/O Introduction - University Of Illinoiscoecsl.ece.illinois.edu/me461/Lectures/DigitalIOUserguide.pdf1/2/4/8 DV SS DV CC TAxCLK 1 0 1 TASSELx 3 2 1 0 ID.x 16-bit Timer

8.2.5 Function Select Registers PxSEL Port pins are often multiplexed with other peripheral module functions. See the device-specific data sheet to determine pin functions. Each PxSEL bit is used to select the pin function - I/O port or peripheral module function.

7 6 5 4 3 2 1 0 PxSEL.7 PxSEL.6 PxSEL.5 PxSEL.4 PxSEL.3 PxSEL.2 PxSEL.1 PxSEL.0

rw (0) (P2SEL rw(1))

rw (0) (P2SEL rw(1))

rw (0) rw (0) rw (0) rw (0) rw (0) rw (0)

 

PxSEL.0 Bit 0 0 Select I/O function, pin is Px.0 1 Peripheral module function selected (See DataSheet)

PxSEL.1 Bit 1 0 Select I/O function, pin is Px.1 1 Peripheral module function selected (See DataSheet)

PxSEL.2 Bit 2 0 Select I/O function, pin is Px.2 1 Peripheral module function selected (See DataSheet)

PxSEL.3 Bit 3 0 Select I/O function, pin is Px.3 1 Peripheral module function selected (See DataSheet)

PxSEL.4 Bit 4 0 Select I/O function, pin is Px.4 1 Peripheral module function selected (See DataSheet)

PxSEL.5 Bit 5 0 Select I/O function, pin is Px.5 1 Peripheral module function selected (See DataSheet)

PxSEL.6 Bit 6 0 Select I/O function, pin is Px.6 1 Peripheral module function selected (See DataSheet)

PxSEL.7 Bit 7 0 Select I/O function, pin is Px.7 1 Peripheral module function selected (See DataSheet)

Setting PxSEL = 1 does not automatically set the pin direction. Other peripheral module functions may require the PxDIR bits to be configured according to the direction needed for the module function. See the pin schematics in the device-specific data sheet.

Page 11: 8.1 Digital I/O Introduction - University Of Illinoiscoecsl.ece.illinois.edu/me461/Lectures/DigitalIOUserguide.pdf1/2/4/8 DV SS DV CC TAxCLK 1 0 1 TASSELx 3 2 1 0 ID.x 16-bit Timer

8.2.7 P1 and P2 Interrupts Each pin in ports P1 and P2 have interrupt capability, configured with the PxIFG, PxIE, and PxIES registers. All P1 pins source a single interrupt vector, and all P2 pins source a different single interrupt vector. The PxIFG register can be tested to determine the source of a P1 or P2 interrupt. 8.2.7.1 Interrupt Flag Registers P1IFG, P2IFG Each PxIFGx bit is the interrupt flag for its corresponding I/O pin and is set when the selected input signal edge occurs at the pin. All PxIFGx interrupt flags request an interrupt when their corresponding PxIE bit and the GIE bit are set. Each PxIFG flag must be reset with software. Software can also set each PxIFG flag, providing a way to generate a software initiated interrupt.

7 6 5 4 3 2 1 0 PxIFG.7 PxIFG.6 PxIFG.5 PxIFG.4 PxIFG.3 PxIFG.2 PxIFG.1 PxIFG.0

rw (0) rw (0) rw (0) rw (0) rw (0) rw (0) rw (0) rw (0)  

PxIFG.0 Bit 0 0 Port Pin0, No interrupt is pending 1 Port Pin0, An interrupt is pending

PxIFG.1 Bit 1 0 Port Pin1, No interrupt is pending 1 Port Pin1, An interrupt is pending

PxIFG.2 Bit 2 0 Port Pin2, No interrupt is pending 1 Port Pin2, An interrupt is pending

PxIFG.3 Bit 3 0 Port Pin3, No interrupt is pending 1 Port Pin3, An interrupt is pending

PxIFG.4 Bit 4 0 Port Pin4, No interrupt is pending 1 Port Pin4, An interrupt is pending

PxIFG.5 Bit 5 0 Port Pin5, No interrupt is pending 1 Port Pin5, An interrupt is pending

PxIFG.6 Bit 6 0 Port Pin6, No interrupt is pending 1 Port Pin6, An interrupt is pending

PxIFG.7 Bit 7 0 Port Pin7, No interrupt is pending 1 Port Pin7, An interrupt is pending

Only transitions, not static levels, cause interrupts. If any PxIFGx flag becomes set during a Px interrupt service routine, or is set after the RETI instruction of a Px interrupt service routine is executed, the set PxIFGx flag generates another interrupt. This ensures that each transition is acknowledged. NOTE: PxIFG Flags When Changing PxOUT or PxDIR Writing to P1OUT, P1DIR, P2OUT, or P2DIR can result in setting the corresponding P1IFG or P2IFG flags. 8.2.7.2 Interrupt Edge Select Registers P1IES, P2IES Each PxIES bit selects the interrupt edge for the corresponding I/O pin.

7 6 5 4 3 2 1 0 PxIES.7 PxIES.6 PxIES.5 PxIES.4 PxIES.3 PxIES.2 PxIES1 PxIES.0

rw (x) rw (x) rw (x) rw (x) rw (x) rw (x) rw (x) rw (x)  

PxIES.0 Bit 0 0 Pin0, PxIFG.0 flag is set with a low-to-high transition 1 Pin0, PxIFG.0 flag is set with a high-to-low transition

PxIES.1 Bit 1 0 Pin1, PxIFG.1 flag is set with a low-to-high transition 1 Pin1, PxIFG.1 flag is set with a high-to-low transition

PxIES.2 Bit 2 0 Pin2, PxIFG.2 flag is set with a low-to-high transition 1 Pin2, PxIFG.2 flag is set with a high-to-low transition

PxIES.3 Bit 3 0 Pin3, PxIFG.3 flag is set with a low-to-high transition 1 Pin3, PxIFG.3 flag is set with a high-to-low transition

PxIES.4 Bit 4 0 Pin4, PxIFG.4 flag is set with a low-to-high transition 1 Pin4, PxIFG.4 flag is set with a high-to-low transition

PxIES.5 Bit 5 0 Pin5, PxIFG.5 flag is set with a low-to-high transition 1 Pin5, PxIFG.5 flag is set with a high-to-low transition

PxIES.6 Bit 6 0 Pin6, PxIFG.6 flag is set with a low-to-high transition 1 Pin6, PxIFG.6 flag is set with a high-to-low transition

PxIES.7 Bit 7 0 Pin7, PxIFG.7 flag is set with a low-to-high transition 1 Pin7, PxIFG.7 flag is set with a high-to-low transition

Page 12: 8.1 Digital I/O Introduction - University Of Illinoiscoecsl.ece.illinois.edu/me461/Lectures/DigitalIOUserguide.pdf1/2/4/8 DV SS DV CC TAxCLK 1 0 1 TASSELx 3 2 1 0 ID.x 16-bit Timer

8.2.7.3 Interrupt Enable P1IE, P2IE Each PxIE bit enables the associated PxIFG interrupt flag

7 6 5 4 3 2 1 0 PxIE.7 PxIE.6 PxIE.5 PxIE.4 PxIE.3 PxIE.2 PxIE.1 PxIE.0 rw (0) rw (0) rw (0) rw (0) rw (0) rw (0) rw (0) rw (0)

. PxIE.0 Bit 0 0 PxIE.0 interrupt is disabled

1 PxIE.0 interrupt is enabled PxIE.1 Bit 1 0 PxIE.1 interrupt is disabled

1 PxIE.1 interrupt is enabled PxIE.2 Bit 2 0 PxIE.2 interrupt is disabled

1 PxIE.2 interrupt is enabled PxIE.3 Bit 3 0 PxIE.3 interrupt is disabled

1 PxIE.3 interrupt is enabled PxIE.4 Bit 4 0 PxIE.4 interrupt is disabled

1 PxIE.4 interrupt is enabled PxIE.5 Bit 5 0 PxIE.5 interrupt is disabled

1 PxIE.5 interrupt is enabled PxIE.6 Bit 6 0 PxIE.6 interrupt is disabled

1 PxIE.6 interrupt is enabled PxIE.7 Bit 7 0 PxIE.7 interrupt is disabled

1 PxIE.7 interrupt is enabled

Page 13: 8.1 Digital I/O Introduction - University Of Illinoiscoecsl.ece.illinois.edu/me461/Lectures/DigitalIOUserguide.pdf1/2/4/8 DV SS DV CC TAxCLK 1 0 1 TASSELx 3 2 1 0 ID.x 16-bit Timer

Direction0: Input1: Output

P1SEL.x

1

0P1DIR.x

P1IN.x

P1IRQ.x

D

EN

Module X IN

1

0

Module X OUT

P1OUT.x

InterruptEdgeSelect

Q

EN

Set

P1SEL.x

P1IES.x

P1IFG.x

P1IE.x

P1.0/TACLK/ADC10CLKP1.1/TA0P1.2/TA1P1.3/TA2

1

0DVSS

DVCC

P1REN.xPad Logic

1

MSP430F22x2MSP430F22x4

SLAS504G –JULY 2006–REVISED AUGUST 2012 www.ti.com

APPLICATION INFORMATION

Port P1 Pin Schematic: P1.0 to P1.3, Input/Output With Schmitt Trigger

Table 21. Port P1 (P1.0 to P1.3) Pin Functions

CONTROL BITS/SIGNALSPIN NAME (P1.x) x FUNCTION

P1DIR.x P1SEL.x

P1.0 (1) I: 0; O: 1 0

P1.0/TACLK/ADC10CLK 0 Timer_A3.TACLK 0 1

ADC10CLK 1 1

P1.1 (1) (I/O) I: 0; O: 1 0

P1.1/TA0 1 Timer_A3.CCI0A 0 1

Timer_A3.TA0 1 1

P1.2 (1) (I/O) I: 0; O: 1 0

P1.2/TA1 2 Timer_A3.CCI1A 0 1

Timer_A3.TA1 1 1

P1.3 (1) (I/O) I: 0; O: 1 0

P1.3/TA2 3 Timer_A3.CCI2A 0 1

Timer_A3.TA2 1 1

(1) Default after reset (PUC/POR)

58 Copyright © 2006–2012, Texas Instruments Incorporated

Page 14: 8.1 Digital I/O Introduction - University Of Illinoiscoecsl.ece.illinois.edu/me461/Lectures/DigitalIOUserguide.pdf1/2/4/8 DV SS DV CC TAxCLK 1 0 1 TASSELx 3 2 1 0 ID.x 16-bit Timer

BusKeeper

EN

Direction0: Input1: Output

P1SEL.x

1

0P1DIR.x

P1IN.x

P1IRQ.x

D

EN

Module X IN

1

0

Module X OUT

P1OUT.x

InterruptEdgeSelect

Q

EN

Set

P1SEL.x

P1IES.x

P1IFG.x

P1IE.x

P1.4/SMCLK/TCK

P1.5/TA0/TMSP1.6/TA1/TDI

1

0DVSS

DVCC

P1REN.x

To JTAG

From JTAG

1

Pad Logic

MSP430F22x2MSP430F22x4

www.ti.com SLAS504G –JULY 2006–REVISED AUGUST 2012

Port P1 Pin Schematic: P1.4 to P1.6, Input/Output With Schmitt Trigger and In-System AccessFeatures

Table 22. Port P1 (P1.4 to P1.6) Pin Functions

CONTROL BITS/SIGNALS (1)

PIN NAME (P1.x) x FUNCTIONP1DIR.x P1SEL.x 4-Wire JTAG

P1.4 (2) (I/O) I: 0; O: 1 0 0

P1.4/SMCLK/TCK 4 SMCLK 1 1 0

TCK X X 1

P1.5 (2) (I/O) I: 0; O: 1 0 0

P1.5/TA0/TMS 5 Timer_A3.TA0 1 1 0

TMS X X 1

P1.6 (2) (I/O) I: 0; O: 1 0 0

P1.6/TA1/TDI/TCLK 6 Timer_A3.TA1 1 1 0

TDI/TCLK (3) X X 1

(1) X = Don't care(2) Default after reset (PUC/POR)(3) Function controlled by JTAG

Copyright © 2006–2012, Texas Instruments Incorporated 59

Page 15: 8.1 Digital I/O Introduction - University Of Illinoiscoecsl.ece.illinois.edu/me461/Lectures/DigitalIOUserguide.pdf1/2/4/8 DV SS DV CC TAxCLK 1 0 1 TASSELx 3 2 1 0 ID.x 16-bit Timer

From JTAG

From JTAG (TDO)

BusKeeper

EN

Direction

0: Input1: Output

P1SEL.7

1

0P1DIR.7

P1IN.7

P1IRQ.7

D

EN

Module X IN

1

0

Module X OUT

P1OUT.7

InterruptEdgeSelect

Q

EN

Set

P1SEL.7

P1IES.7

P1IFG.7

P1IE.7

P1.7/TA2/TDO/TDI

1

0DVSS

DVCC

P1REN.7

To JTAG

From JTAG

1

Pad Logic

MSP430F22x2MSP430F22x4

SLAS504G –JULY 2006–REVISED AUGUST 2012 www.ti.com

Port P1 Pin Schematic: P1.7, Input/Output With Schmitt Trigger and In-System Access Features

Table 23. Port P1 (P1.7) Pin Functions

CONTROL BITS/SIGNALS (1)

PIN NAME (P1.x) x FUNCTIONP1DIR.x P1SEL.x 4-Wire JTAG

P1.7 (2) (I/O) I: 0; O: 1 0 0

P1.7/TA2/TDO/TDI 7 Timer_A3.TA2 1 1 0

TDO/TDI (3) X X 1

(1) X = Don't care(2) Default after reset (PUC/POR)(3) Function controlled by JTAG

60 Copyright © 2006–2012, Texas Instruments Incorporated

Page 16: 8.1 Digital I/O Introduction - University Of Illinoiscoecsl.ece.illinois.edu/me461/Lectures/DigitalIOUserguide.pdf1/2/4/8 DV SS DV CC TAxCLK 1 0 1 TASSELx 3 2 1 0 ID.x 16-bit Timer

Bus

Keeper

EN

Direction0: Input1: Output

P2SEL.x

1

0P2DIR.x

P2IN.x

P2IRQ.x

D

EN

Module X IN

1

0

Module X OUT

P2OUT.x

InterruptEdgeSelect

Q

EN

Set

P2SEL.x

P2IES.x

P2IFG.x

P2IE.x

P2.0/ACLK/A0/OA0I0P2.2/TA0/A2/OA0I1

1

0DVSS

DVCC

P2REN.x

ADC10AE0.y

Pad Logic

INCHx = y

To ADC 10

1

OA0

+

MSP430F22x2MSP430F22x4

www.ti.com SLAS504G –JULY 2006–REVISED AUGUST 2012

Port P2 Pin Schematic: P2.0, P2.2, Input/Output With Schmitt Trigger

Table 24. Port P2 (P2.0, P2.2) Pin Functions

CONTROL BITS/SIGNALS (1)

Pin Name (P2.x) x y FUNCTIONP2DIR.x P2SEL.x ADC10AE0.y

P2.0 (2) (I/O) I: 0; O: 1 0 0

P2.0/ACLK/A0/OA0I0 0 0 ACLK 1 1 0

A0/OA0I0 (3) X X 1

P2.2 (2) (I/O) I: 0; O: 1 0 0

Timer_A3.CCI0B 0 1 0P2.2/TA0/A2/OA0I1 2 2

Timer_A3.TA0 1 1 0

A2/OA0I1 (3) X X 1

(1) X = Don't care(2) Default after reset (PUC/POR)(3) Setting the ADC10AE0.y bit disables the output driver as well as the input Schmitt trigger to prevent parasitic cross currents when

applying analog signals.

Copyright © 2006–2012, Texas Instruments Incorporated 61

Page 17: 8.1 Digital I/O Introduction - University Of Illinoiscoecsl.ece.illinois.edu/me461/Lectures/DigitalIOUserguide.pdf1/2/4/8 DV SS DV CC TAxCLK 1 0 1 TASSELx 3 2 1 0 ID.x 16-bit Timer

1

OAFCxOAPMx

OAADCx

To OA0 Feedback Network1

(OAADCx = 10 or OAFCx = 000) and OAPMx> 00

BusKeeper

EN

Direction0: Input1: Output

P2SEL.1

1

0P2DIR.1

P2IN.1

P2IRQ.1

D

EN

Module X IN

1

0

Module X OUT

P2OUT.1

InterruptEdgeSelect

Q

EN

Set

P2SEL.1

P2IES.1

P2IFG.1

P2IE.1

P2.1/TAINCLK/SMCLK/A1/OA0O

1

0DVSS

DVCC

P2REN.1

ADC10AE0.1

Pad Logic

INCHx = 1

To ADC 10

1

OA0

+

1

MSP430F22x2MSP430F22x4

SLAS504G –JULY 2006–REVISED AUGUST 2012 www.ti.com

Port P2 Pin Schematic: P2.1, Input/Output With Schmitt Trigger

Table 25. Port P2 (P2.1) Pin Functions

CONTROL BITS/SIGNALS (1)

PIN NAME (P2.x) x y FUNCTIONP2DIR.x P2SEL.x ADC10AE0.y

P2.1 (2) (I/O) I: 0; O: 1 0 0

Timer_A3.INCLK 0 1 0P2.1/TAINCLK/SMCLK/ 1 1A1/OA0O SMCLK 1 1 0

A1/OA0O (3) X X 1

(1) X = Don't care(2) Default after reset (PUC/POR)(3) Setting the ADC10AE0.y bit disables the output driver as well as the input Schmitt trigger to prevent parasitic cross currents when

applying analog signals.

62 Copyright © 2006–2012, Texas Instruments Incorporated

Page 18: 8.1 Digital I/O Introduction - University Of Illinoiscoecsl.ece.illinois.edu/me461/Lectures/DigitalIOUserguide.pdf1/2/4/8 DV SS DV CC TAxCLK 1 0 1 TASSELx 3 2 1 0 ID.x 16-bit Timer

BusKeeper

EN

Direction0: Input

1: Output

P2SEL.3

1

0P2DIR.3

P2IN.3

P2IRQ.3

D

EN

Module X IN

1

0

Module X OUT

P2OUT.3

InterruptEdgeSelect

Q

EN

Set

P2SEL.3

P2IES.3

P2IFG.3

P2IE.3

1

0DVSS

DVCC

P2REN.3

ADC10AE0.3

Pad Logic

INCHx = 3

To ADC 10

1

OA1

+

1

OAFCxOAPMx

OAADCx

To OA1 Feedback Network

To ADC 10 VR− 1

0

SREF2

VSS

P2.3/TA1/A3/VREF−/VeREF−/OA1I1/OA1O

1

(OAADCx = 10 or OAFCx = 000) and OAPMx > 00

MSP430F22x2MSP430F22x4

www.ti.com SLAS504G –JULY 2006–REVISED AUGUST 2012

Port P2 Pin Schematic: P2.3, Input/Output With Schmitt Trigger

Copyright © 2006–2012, Texas Instruments Incorporated 63

Page 19: 8.1 Digital I/O Introduction - University Of Illinoiscoecsl.ece.illinois.edu/me461/Lectures/DigitalIOUserguide.pdf1/2/4/8 DV SS DV CC TAxCLK 1 0 1 TASSELx 3 2 1 0 ID.x 16-bit Timer

MSP430F22x2MSP430F22x4

SLAS504G –JULY 2006–REVISED AUGUST 2012 www.ti.com

Table 26. Port P2 (P2.3) Pin Functions

CONTROL BITS/SIGNALS (1)

PIN NAME (P2.x) x y FUNCTIONP2DIR.x P2SEL.x ADC10AE0.y

P2.3 (2) (I/O) I: 0; O: 1 0 0

Timer_A3.CCI1B 0 1 0P2.3/TA1/A3/VREF- 3 3/VeREF-/ OA1I1/OA1O Timer_A3.TA1 1 1 0

A3/VREF-/VeREF-/OA1I1/OA1O (3) X X 1

(1) X = Don't care(2) Default after reset (PUC/POR)(3) Setting the ADC10AE0.y bit disables the output driver as well as the input Schmitt trigger to prevent parasitic cross currents when

applying analog signals.

64 Copyright © 2006–2012, Texas Instruments Incorporated

Page 20: 8.1 Digital I/O Introduction - University Of Illinoiscoecsl.ece.illinois.edu/me461/Lectures/DigitalIOUserguide.pdf1/2/4/8 DV SS DV CC TAxCLK 1 0 1 TASSELx 3 2 1 0 ID.x 16-bit Timer

BusKeeper

EN

Direction0: Input1: Output

P2SEL.4

1

0P2DIR.4

P2IN.4

P2IRQ.4

D

EN

Module X IN

1

0

Module X OUT

P2OUT.4

InterruptEdge

Select

Q

EN

Set

P2SEL.4

P2IES.4

P2IFG.4

P2IE.4

P2.4/TA2/A4/VREF+/VeREF+/OA1I0

1

0DVSS

DVCC

P2REN.4

ADC10AE0.4

Pad Logic

INCHx = 4

To ADC 10

1

To/from ADC10

positive reference

OA1

+

MSP430F22x2MSP430F22x4

www.ti.com SLAS504G –JULY 2006–REVISED AUGUST 2012

Port P2 Pin Schematic: P2.4, Input/Output With Schmitt Trigger

Table 27. Port P2 (P2.4) Pin Functions

CONTROL BITS/SIGNALS (1)

PIN NAME (P2.x) x y FUNCTIONP2DIR.x P2SEL.x ADC10AE0.y

P2.4 (2) (I/O) I: 0; O: 1 0 0P2.4/TA2/A4/VREF+/ 4 4 Timer_A3.TA2 1 1 0VeREF+/ OA1I0

A4/VREF+/VeREF+/OA1I0 (3) X X 1

(1) X = Don't care(2) Default after reset (PUC/POR)(3) Setting the ADC10AE0.y bit disables the output driver as well as the input Schmitt trigger to prevent parasitic cross currents when

applying analog signals.

Copyright © 2006–2012, Texas Instruments Incorporated 65

Page 21: 8.1 Digital I/O Introduction - University Of Illinoiscoecsl.ece.illinois.edu/me461/Lectures/DigitalIOUserguide.pdf1/2/4/8 DV SS DV CC TAxCLK 1 0 1 TASSELx 3 2 1 0 ID.x 16-bit Timer

BusKeeper

EN

Direction0: Input1: Output

P2SEL.x

1

0P2DIR.x

P2IN.x

P2IRQ.x

D

EN

Module X IN

1

0

Module X OUT

P2OUT.x

InterruptEdgeSelect

Q

EN

Set

P2SEL.x

P2IES.x

P2IFG.x

P2IE.x

P2.5/ROSC

1

0DVSS

DVCC

P2REN.x

DCOR

Pad Logic

To DCO

1

MSP430F22x2MSP430F22x4

SLAS504G –JULY 2006–REVISED AUGUST 2012 www.ti.com

Port P2 Pin Schematic: P2.5, Input/Output With Schmitt Trigger and External ROSC for DCO

Table 28. Port P2 (P2.5) Pin Functions

CONTROL BITS/SIGNALS (1)

PIN NAME (P2.x) x FUNCTIONP2DIR.x P2SEL.x DCOR

P2.5 (2) (I/O) I: 0; O: 1 0 0

N/A (3) 0 1 0P2.5/ROSC 5

DVSS 1 1 0

ROSC X X 1

(1) X = Don't care(2) Default after reset (PUC/POR)(3) N/A = Not available or not applicable

66 Copyright © 2006–2012, Texas Instruments Incorporated

Page 22: 8.1 Digital I/O Introduction - University Of Illinoiscoecsl.ece.illinois.edu/me461/Lectures/DigitalIOUserguide.pdf1/2/4/8 DV SS DV CC TAxCLK 1 0 1 TASSELx 3 2 1 0 ID.x 16-bit Timer

LFXT1 off

P2SEL.7

BusKeeper

EN

Direction0: Input1: Output

P2SEL.6

1

0P2DIR.6

P2IN.6

P2IRQ.6

D

EN

Module X IN

1

0

Module X OUT

P2OUT.6

InterruptEdgeSelect

Q

EN

Set

P2SEL.6

P2IES.6

P2IFG.6

P2IE.6

P2.6/XIN

1

0DVSS

DVCC

P2REN.6

Pad Logic

LFXT1 OscillatorBCSCTL3.LFXT1Sx = 11

P2.7/XOUT

0

1

1

LFXT1CLK

MSP430F22x2MSP430F22x4

www.ti.com SLAS504G –JULY 2006–REVISED AUGUST 2012

Port P2 Pin Schematic: P2.6, Input/Output With Schmitt Trigger and Crystal Oscillator Input

Table 29. Port P2 (P2.6) Pin Functions

CONTROL BITS/SIGNALS (1)

PIN NAME (P2.x) x FUNCTIONP2DIR.x P2SEL.x

P2.6 (I/O) I: 0; O: 1 0P2.6/XIN 6

XIN (2) X 1

(1) X = Don't care(2) Default after reset (PUC/POR)

Copyright © 2006–2012, Texas Instruments Incorporated 67

Page 23: 8.1 Digital I/O Introduction - University Of Illinoiscoecsl.ece.illinois.edu/me461/Lectures/DigitalIOUserguide.pdf1/2/4/8 DV SS DV CC TAxCLK 1 0 1 TASSELx 3 2 1 0 ID.x 16-bit Timer

LFXT1 off

P2SEL.6

BusKeeper

EN

Direction0: Input1: Output

P2SEL.7

1

0P2DIR.7

P2IN.7

P2IRQ.7

D

EN

Module X IN

1

0

Module X OUT

P2OUT.7

InterruptEdgeSelect

Q

EN

Set

P2SEL.7

P2IES.7

P2IFG.7

P2IE.7

P2.7/XOUT

1

0DVSS

DVCC

P2REN.7

Pad Logic

LFXT1 OscillatorBCSCTL3.LFXT1Sx = 11

0

1

1

LFXT1CLK From P2.6/XIN P2.6/XIN

MSP430F22x2MSP430F22x4

SLAS504G –JULY 2006–REVISED AUGUST 2012 www.ti.com

Port P2 Pin Schematic: P2.7, Input/Output With Schmitt Trigger and Crystal Oscillator Output

Table 30. Port P2 (P2.7) Pin Functions

CONTROL BITS/SIGNALS (1)

PIN NAME (P2.x) x FUNCTIONP2DIR.x P2SEL.x

P2.7 (I/O) I: 0; O: 1 0XOUT/P2.7 7

XOUT (2) (3) X 1

(1) X = Don't care(2) Default after reset (PUC/POR)(3) If the pin XOUT/P2.7 is used as an input a current can flow until P2SEL.7 is cleared due to the oscillator output driver connection to this

pin after reset.

68 Copyright © 2006–2012, Texas Instruments Incorporated

Page 24: 8.1 Digital I/O Introduction - University Of Illinoiscoecsl.ece.illinois.edu/me461/Lectures/DigitalIOUserguide.pdf1/2/4/8 DV SS DV CC TAxCLK 1 0 1 TASSELx 3 2 1 0 ID.x 16-bit Timer

BusKeeper

EN

Direction

0: Input1: Output

P3SEL.0

1

0P3DIR.0

P3IN.0

D

EN

Module X IN

1

0

Module X OUT

P3OUT.0

1

0DVSS

DVCC

P3REN.0

ADC10AE0.5

Pad Logic

INCHx = 5

To ADC 10

1

USCI Direction

Control

P3.0/UCB0STE/UCA0CLK/A5

MSP430F22x2MSP430F22x4

www.ti.com SLAS504G –JULY 2006–REVISED AUGUST 2012

Port P3 Pin Schematic: P3.0, Input/Output With Schmitt Trigger

Table 31. Port P3 (P3.0) Pin Functions

CONTROL BITS/SIGNALS (1)

PIN NAME (P1.x) x y FUNCTIONP3DIR.x P3SEL.x ADC10AE0.y

P3.0 (2) (I/O) I: 0; O: 1 0 0P3.0/UCB0STE/ 0 5 UCB0STE/UCA0CLK (3) (4) X 1 0UCA0CLK/A5

A5 (5) X X 1

(1) X = Don't care(2) Default after reset (PUC/POR)(3) The pin direction is controlled by the USCI module.(4) UCA0CLK function takes precedence over UCB0STE function. If the pin is required as UCA0CLK input or output, USCI_B0 is forced to

3-wire SPI mode if 4-wire SPI mode is selected.(5) Setting the ADC10AE0.y bit disables the output driver as well as the input Schmitt trigger to prevent parasitic cross currents when

applying analog signals.

Copyright © 2006–2012, Texas Instruments Incorporated 69

Page 25: 8.1 Digital I/O Introduction - University Of Illinoiscoecsl.ece.illinois.edu/me461/Lectures/DigitalIOUserguide.pdf1/2/4/8 DV SS DV CC TAxCLK 1 0 1 TASSELx 3 2 1 0 ID.x 16-bit Timer

BusKeeper

EN

Direction0: Input1: Output

P3SEL.x

1

0P3DIR.x

P3IN.x

D

EN

Module X IN

1

0

Module X OUT

P3OUT.x

1

0DVSS

DVCC

P3REN.x

Pad Logic

1

USCI DirectionControl

DVSS

P3.1/UCB0SIMO/UCB0SDA

P3.2/UCB0SOMI/UCB0SCL

P3.3/UCB0CLK/UCA0STE

P3.4/UCA0TXD/UCA0SIMO

P3.5/UCA0RXD/UCA0SOMI

MSP430F22x2MSP430F22x4

SLAS504G –JULY 2006–REVISED AUGUST 2012 www.ti.com

Port P3 Pin Schematic: P3.1 to P3.5, Input/Output With Schmitt Trigger

Table 32. Port P3 (P3.1 to P3.5) Pin Functions

CONTROL BITS/SIGNALS (1)

PIN NAME (P3.x) x FUNCTIONP3DIR.x P3SEL.x

P3.1 (2) (I/O) I: 0; O: 1 0P3.1/UCB0SIMO/UCB0SDA 1

UCB0SIMO/UCB0SDA (3) X 1

P3.2 (2) (I/O) I: 0; O: 1 0P3.2/UCB0SOMI/UCB0SCL 2

UCB0SOMI/UCB0SCL (3) X 1

P3.3 (2) (I/O) I: 0; O: 1 0P3.3/UCB0CLK/UCA0STE 3

UCB0CLK/UCA0STE (3) (4) X 1

P3.4 (2) (I/O) I: 0; O: 1 0P3.4/UCA0TXD/UCA0SIMO 4

UCA0TXD/UCA0SIMO (3) X 1

P3.5 (2) (I/O) I: 0; O: 1 0P3.5/UCA0RXD/UCA0SOMI 5

UCA0RXD/UCA0SOMI (3) X 1

(1) X = Don't care(2) Default after reset (PUC/POR)(3) The pin direction is controlled by the USCI module.(4) UCB0CLK function takes precedence over UCA0STE function. If the pin is required as UCB0CLK input or output, USCI_A0 is forced to

3-wire SPI mode even if 4-wire SPI mode is selected.

70 Copyright © 2006–2012, Texas Instruments Incorporated

Page 26: 8.1 Digital I/O Introduction - University Of Illinoiscoecsl.ece.illinois.edu/me461/Lectures/DigitalIOUserguide.pdf1/2/4/8 DV SS DV CC TAxCLK 1 0 1 TASSELx 3 2 1 0 ID.x 16-bit Timer

Bus

Keeper

EN

Direction0: Input1: Output

P3SEL.x

1

0P3DIR.x

P3IN.x

D

EN

Module X IN

1

0

Module X OUT

P3OUT.x

P3.6/A6/OA0I2P3.7/A7/OA1I2

1

0DVSS

DVCC

P3REN.x

ADC10AE0.y

Pad Logic

INCHx = y

To ADC 10

1

OA0/1

+

DVSS

MSP430F22x2MSP430F22x4

www.ti.com SLAS504G –JULY 2006–REVISED AUGUST 2012

Port P3 Pin Schematic: P3.6 to P3.7, Input/Output With Schmitt Trigger

Table 33. Port P3 (P3.6, P3.7) Pin Functions

CONTROL BITS/SIGNALS (1)

PIN NAME (P3.x) x y FUNCTIONP3DIR.x P3SEL.x ADC10AE0.y

P3.6 (2) (I/O) I: 0; O: 1 0 0P3.6/A6/OA0I2 6 6

A6/OA0I2 (3) X X 1

P3.7 (2) (I/O) I: 0; O: 1 0 0P3.7/A7/OA1I2 7 7

A7/OA1I2 (3) X X 1

(1) X = Don't care(2) Default after reset (PUC/POR)(3) Setting the ADC10AE0.y bit disables the output driver as well as the input Schmitt trigger to prevent parasitic cross currents when

applying analog signals.

Copyright © 2006–2012, Texas Instruments Incorporated 71

Page 27: 8.1 Digital I/O Introduction - University Of Illinoiscoecsl.ece.illinois.edu/me461/Lectures/DigitalIOUserguide.pdf1/2/4/8 DV SS DV CC TAxCLK 1 0 1 TASSELx 3 2 1 0 ID.x 16-bit Timer

BusKeeper

EN

Direction

0: Input1: Output

P4SEL.x

1

0P4DIR.x

P4IN.x

D

EN

Module X IN

1

0

Module X OUT

P4OUT.x

P4.0/TB0P4.1/TB1P4.2/TB2

1

0DVSS

DVCC

P4REN.x

Pad Logic

1

P4DIR.6

P4SEL.6

ADC10AE1.7

P4.6/TBOUTH/A15/OA1I3

Timer_B Output Tristate Logic

MSP430F22x2MSP430F22x4

SLAS504G –JULY 2006–REVISED AUGUST 2012 www.ti.com

Port P4 Pin Schematic: P4.0 to P4.2, Input/Output With Schmitt Trigger

Table 34. Port P4 (P4.0 to P4.2) Pin Functions

CONTROL BITS/SIGNALSPIN NAME (P4.x) x FUNCTION

P4DIR.x P4SEL.x

P4.0 (1) (I/O) I: 0; O: 1 0

P4.0/TB0 0 Timer_B3.CCI0A 0 1

Timer_B3.TB0 1 1

P4.1 (1) (I/O) I: 0; O: 1 0

P4.1/TB1 1 Timer_B3.CCI1A 0 1

Timer_B3.TB1 1 1

P4.2 (1) (I/O) I: 0; O: 1 0

P4.2/TB2 2 Timer_B3.CCI2A 0 1

Timer_B3.TB2 1 1

(1) Default after reset (PUC/POR)

72 Copyright © 2006–2012, Texas Instruments Incorporated

Page 28: 8.1 Digital I/O Introduction - University Of Illinoiscoecsl.ece.illinois.edu/me461/Lectures/DigitalIOUserguide.pdf1/2/4/8 DV SS DV CC TAxCLK 1 0 1 TASSELx 3 2 1 0 ID.x 16-bit Timer

OAPMx

OAADCx

To OA0/1 Feedback Network1

OAADCx = 01 and OAPMx > 00

BusKeeper

EN

Direction0: Input1: Output

P4SEL.x

1

0P4DIR.x

P4IN.x

D

EN

Module X IN

1

0

Module X OUT

P4OUT.x

P4.3/TB0/A12/OA0OP4.4/TB1/A13/OA1O

1

0DVSS

DVCC

P4REN.x

ADC10AE1.y

Pad Logic

INCHx = 8+y

To ADC 10

1

OA0/1

+

1

P4DIR.6

P4SEL.6

ADC10AE1.7

P4.6/TBOUTH/A15/OA1I3

Timer_B Output Tristate Logic

MSP430F22x2MSP430F22x4

www.ti.com SLAS504G –JULY 2006–REVISED AUGUST 2012

Port P4 Pin Schematic: P4.3 to P4.4, Input/Output With Schmitt Trigger

†If OAADCx = 11 and not OAFCx = 000, the ADC input A12 or A13 is internally connected to the OA0 or OA1 output,respectively, and the connections from the ADC and the operational amplifiers to the pad are disabled.

Copyright © 2006–2012, Texas Instruments Incorporated 73

Page 29: 8.1 Digital I/O Introduction - University Of Illinoiscoecsl.ece.illinois.edu/me461/Lectures/DigitalIOUserguide.pdf1/2/4/8 DV SS DV CC TAxCLK 1 0 1 TASSELx 3 2 1 0 ID.x 16-bit Timer

MSP430F22x2MSP430F22x4

SLAS504G –JULY 2006–REVISED AUGUST 2012 www.ti.com

Table 35. Port P4 (P4.3 to P4.4) Pin Functions

CONTROL BITS/SIGNALS (1)

PIN NAME (P4.x) x y FUNCTIONP4DIR.x P4SEL.x ADC10AE1.y

P4.3 (2) (I/O) I: 0; O: 1 0 0

Timer_B3.CCI0B 0 1 0P4.3/TB0/A12/OA0O 3 4

Timer_B3.TB0 1 1 0

A12/OA0O (3) X X 1

P4.4 (2) (I/O) I: 0; O: 1 0 0

Timer_B3.CCI1B 0 1 0P4.4/TB1/A13/OA1O 4 5

Timer_B3.TB1 1 1 0

A13/OA1O (3) X X 1

(1) X = Don't care(2) Default after reset (PUC/POR)(3) Setting the ADC10AE1.y bit disables the output driver as well as the input Schmitt trigger to prevent parasitic cross currents when

applying analog signals.

74 Copyright © 2006–2012, Texas Instruments Incorporated

Page 30: 8.1 Digital I/O Introduction - University Of Illinoiscoecsl.ece.illinois.edu/me461/Lectures/DigitalIOUserguide.pdf1/2/4/8 DV SS DV CC TAxCLK 1 0 1 TASSELx 3 2 1 0 ID.x 16-bit Timer

BusKeeper

EN

Direction0: Input1: Output

P4SEL.5

1

0P4DIR.5

P4IN.5

D

EN

Module X IN

1

0

Module X OUT

P4OUT.5

P4.5/TB3/A14/OA0I3

1

0DVSS

DVCC

P4REN.5

ADC10AE1.6

Pad Logic

INCHx = 14

To ADC 10

1

P4DIR.6

P4SEL.6

ADC10AE1.7

P4.6/TBOUTH/A15/OA1I3

Timer_B Output Tristate Logic

OA0

+

MSP430F22x2MSP430F22x4

www.ti.com SLAS504G –JULY 2006–REVISED AUGUST 2012

Port P4 Pin Schematic: P4.5, Input/Output With Schmitt Trigger

Table 36. Port P4 (P4.5) Pin Functions

CONTROL BITS/SIGNALS (1)

PIN NAME (P4.x) x y FUNCTIONP4DIR.x P4SEL.x ADC10AE1.y

P4.5 (2) (I/O) I: 0; O: 1 0 0

P4.5/TB3/A14/OA0I3 5 6 Timer_B3.TB2 1 1 0

A14/OA0I3 (3) X X 1

(1) X = Don't care(2) Default after reset (PUC/POR)(3) Setting the ADC10AE1.y bit disables the output driver as well as the input Schmitt trigger to prevent parasitic cross currents when

applying analog signals.

Copyright © 2006–2012, Texas Instruments Incorporated 75

Page 31: 8.1 Digital I/O Introduction - University Of Illinoiscoecsl.ece.illinois.edu/me461/Lectures/DigitalIOUserguide.pdf1/2/4/8 DV SS DV CC TAxCLK 1 0 1 TASSELx 3 2 1 0 ID.x 16-bit Timer

Bus

Keeper

EN

Direction0: Input1: Output

P4SEL.6

1

0P4DIR.6

P4IN.6

D

EN

Module X IN

1

0

Module X OUT

P4OUT.6

1

0DVSS

DVCC

P4REN.6

ADC10AE1.7

Pad Logic

INCHx = 15

To ADC 10

1

OA1

+

P4.6/TBOUTH/A15/OA1I3

MSP430F22x2MSP430F22x4

SLAS504G –JULY 2006–REVISED AUGUST 2012 www.ti.com

Port P4 Pin Schematic: P4.6, Input/Output With Schmitt Trigger

Table 37. Port P4 (P4.6) Pin Functions

CONTROL BITS/SIGNALS (1)

PIN NAME (P4.x) x y FUNCTIONP4DIR.x P4SEL.x ADC10AE1.y

P4.6 (2) (I/O) I: 0; O: 1 0 0

TBOUTH 0 1 0P4.6/TBOUTH/A15/OA1I3 6 7

DVSS 1 1 0

A15/OA1I3 (3) X X 1

(1) X = Don't care(2) Default after reset (PUC/POR)(3) Setting the ADC10AE1.y bit disables the output driver as well as the input Schmitt trigger to prevent parasitic cross currents when

applying analog signals.

76 Copyright © 2006–2012, Texas Instruments Incorporated

Page 32: 8.1 Digital I/O Introduction - University Of Illinoiscoecsl.ece.illinois.edu/me461/Lectures/DigitalIOUserguide.pdf1/2/4/8 DV SS DV CC TAxCLK 1 0 1 TASSELx 3 2 1 0 ID.x 16-bit Timer

BusKeeper

EN

Direction0: Input1: Output

P4SEL.x

1

0P4DIR.x

P4IN.x

D

EN

Module X IN

1

0

Module X OUT

P4OUT.x

P4.7/TBCLK

1

0DVSS

DVCC

P4REN.x

Pad Logic

1

DVSS

MSP430F22x2MSP430F22x4

www.ti.com SLAS504G –JULY 2006–REVISED AUGUST 2012

Port P4 Pin Schematic: P4.7, Input/Output With Schmitt Trigger

Table 38. Port P4 (Pr.7) Pin Functions

CONTROL BITS/SIGNALSPIN NAME (P4.x) x FUNCTION

P4DIR.x P4SEL.x

P4.7 (1) (I/O) I: 0; O: 1 0

P4.7/TBCLK 7 Timer_B3.TBCLK 0 1

DVSS 1 1

(1) Default after reset (PUC/POR)

Copyright © 2006–2012, Texas Instruments Incorporated 77