How do you programmatically detect pin count on an MSP430G2553?
The method below will tell you if a pin exists on the controller.  So, to determine if we're using a 20 or a 28 pin controller, select a Digital Pin that is > 20 and pass it as the parameter to the function below.  If it returns true, you have a 28 pin controller.  If it returns false, you have a 20 pin controller.  I tested this using my MSP430G2553 Launchpad and have the following results:

  showPinExistence(2);
  showPinExistence(3);
  showPinExistence(5);
  showPinExistence(6);
  showPinExistence(7);
  showPinExistence(8);
  showPinExistence(11);
  showPinExistence(15);
  showPinExistence(18);
  showPinExistence(21);
  showPinExistence(22);
  showPinExistence(23);


void showPinExistence(int pin)
{
  Serial.print("Pin ");
  Serial.print(pin);
  Serial.print(" Exists: ");
  Serial.println(pinExists(pin)?"True":"False");
  Serial.flush();
}

bool pinExists(int pin)
{
    bool lowResult;
    bool highResult;

    pinMode(pin, OUTPUT);
    digitalWrite(pin, LOW);
    lowResult = digitalRead(pin);

    digitalWrite(pin, HIGH);
    highResult = digitalRead(pin);

    return lowResult != highResult;
}


Here's the output for LaunchPad with MSP430G2553 (20 Pin):

Pin 2 Exists: True
Pin 3 Exists: True
Pin 5 Exists: True
Pin 6 Exists: True
Pin 7 Exists: True
Pin 8 Exists: True
Pin 11 Exists: True
Pin 15 Exists: True
Pin 18 Exists: True
Pin 21 Exists: False
Pin 22 Exists: False
Pin 23 Exists: False


Here's the output for MSP430G2553 (28 Pin):

Pin 8 Exists: True
Pin 9 Exists: True
Pin 10 Exists: True
Pin 11 Exists: True
Pin 12 Exists: True
Pin 13 Exists: True
Pin 14 Exists: True
Pin 15 Exists: True
Pin 16 Exists: True
Pin 17 Exists: True
Pin 18 Exists: True
Pin 19 Exists: True
Pin 20 Exists: True
Pin 21 Exists: True
Pin 22 Exists: True
Pin 23 Exists: True


I had to start with pin 8 because it didn't like when I attempted to set 2-7 as output pins :-)  Anyway, the point is that you can attempt to set pin 23 as an output pin and write and read its value to determine if the chip you're using is a 20 pin, or if it has more than 20 pins.  I don't have a 32 pin chip, but I would imagine that you could test on a pin greater than 28 to make a determination if it is a 32 pin chip.

Now, after ALL that I've said.  Since writing this, I discovered that there is now 28pin support on GitHub.  I am now using it and referring to pins with their proper P3_0, P2_0 notation instead of directly by Pin number and this seems to be working just fine now.