How to set I/O state to get the minimum power consumption in power saving mode?
In order to save power, those peripherals (ADC module, watchdog) that will not be used temporarily should be disabled before entering the STOP mode. First, set the ports to be input and make sure there is no current flow in the ports and peripheral circuit. As input ports, they have extremely high impendence for the external world. 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 peripheral circuit, if the ports are unfit to be set as input, it can be set to be output with a certain level that determined by the external circuit. For instance, if the pin is connected with a pull-up resistor, it can be configured to output high level signal; if pull-down, it can be set to output low level signal.