Electronic – MSP430 individual pin accesibility

iarmicrocontrollermsp430ti-ccstudio

I'm working on a ultra-low power application and want to enable and access only one pin as output and one pin as input. I'm using the MSP430 microcontroller and CCS for programming. I have two questions.

  • The MSP430 allows accessibility of a whole port. Is it possible to access only the required two pins as input and output (which is possible in PIC)?

  • Doesn't accessing (and enabling) the whole port (8 pins) consume more current compared to accessing (and enabling) a single pin?

Best Answer

The MSP430 organizes the GPIO bits in ports, but when using C statements that set/clear single bits, the compiler will generate bit set/clear commands that affect only single bits (BIS/BIC):

if (P1IN & BIT1) {
    P1OUT |= BIT4;
} else {
    P1OUT &= ~BIT4;
}

This will not consume current for any bits that are not accessed.

In general, GPIO pins do not consume any current, unless

  • output pins actually sink or source current (due to external circuitry), or
  • input pins actually change (or are floating).

The user's guide tells you how to configure unused pins: as output, or as input with a pull-up/-down. (The default setting is input without pull-up/-down, which does not save current, but is the safest setting while the chip is still in reset.)