4.2.4 Pin Setup
When an application leaves some pins of the microcontroller unused, special considerations should be made to keep power consumption down. When the device is in a sleep mode, the power consumption from unused and incorrectly configured pins may be significant.
The most important aspect to consider is avoiding floating pins. Floating pins are pins that are not tied to a defined voltage level. They may behave sporadically based on outside and internal interference. This sporadic behavior may lead to the voltage threshold of transistors being crossed which leads to dynamic power consumption.
Floating pins are avoided by enabling internal pull ups for the pins. This pulls the voltage to a constant logic high level through an internal pull-up resistor. One may also disable the digital input buffer of the pin. This disconnects the digital input circuitry, further lowering the power consumption.
In all applications configured using Atmel START, unused pins are automatically initialized as inputs with the internal pull up enabled. In the advanced keypad application, the unused pins are also initialized in START to disable the digital input circuits.
The following code snippet configures pin PA0 to an input with pull up enabled and the digital input circuit disabled:
/* Set the pin to input */ PORTA.DIRCLR = PIN0_bm; /* Enable pullup and disable digital input buffer */ PORTA.PIN0CTRL = PORT_PULLUPEN_bm | PORT_ISC_INPUT_DISABLE_gc;