How to set I/O state to get the minimum power consumption in power saving modes?
In order to save power, part of peripherals (ADC module, watchdog) that will not be used temporarily should be disabled before entering the STOP mode. First, set the port to be input and make sure there is no current flow in the port and peripheral circuit. As input, the port impedance is taken to be extremely high for the external circuit. As a result, current will not be generated. The normal input voltage should be VSS or VDD, otherwise, tiny current may be generated (1mA @ 2V.). Therefore, considering the existence of IO port and peripheral circuit, if the port is unfit for input, it can be set to be output. Peripheral circuit determines the output level to be high or low. For instance, if the pin is connected with a pull-up resistor, it can be configured to output high level ; if pull-down, it can be set to output low level.