P1IN Register in MSP430

msp430register

Does the register P1IN has default values? I am trying to test a matrix keypad but in register P1IN-1 and P1IN2 are always high.

Best Answer

The User's Guide says:

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.

There is no such thing as a default value; if you do not have an external circuit that drives the input to a specific value, the pin might pick up a random charge from internal or external noise, which results in a random value. This is called a "floating pin", and should always be avoided because a voltage between the "0" and "1" levels can result in a high shoot-through current.

To force the pin to always have a specific value even when not driven by another circuit, use a pull-up or pull-down resistor. The MSP430 has built-in resistors, which can be enabled with the PxREN registers.

Related Topic