Config - is a constant/variable that sets the type of hibernation
Make the microcontroller sleep until a reset or interrupt occurs.
The hibernate command puts the microcontroller into very low power 'hibernation' mode. Unlike the sleep command, which wakes up every 2.3s, hibernate mode enters a state of permanent sleep. The only way to exit this deep sleep is via an external reset or via a hardware interrupt (hserin, hi2cin, etc.).
A new program download from the computer will NOT wake the microcontroller. For best low power performance, ensure any unused inputs are tied high/low, and that no outputs are being actively driven. The hibernate command automatically shuts down any on-board peripherals (timers, pwm etc) and disables the brown out detect circuit (equivalent of an automatic 'disablebod' command). After a hibernate command the brown out detect is always re-enabled, so if the brown out detect feature is not required after the hibernate the user program must disable it again via a 'disablebod' command.
'config' value is used to disable/enable and set the 'ultra low power wake up feature' of analogue pin ADC0. A value of 0 disables this feature.. When enabled, the hibernate will terminate after a capacitor (connected to ADC0) has discharged. This is more energy efficient than using the sleep command. A non-zero config value enables the ULPWU feature on ADC0, and the actual config value sets the charging time (in ms) for the connected capacitor. Therefore the hibernate command first charges the capacitor, then hibernates, and then wakes up again once the capacitor has discharged.
The discharge time is given by the following formula:
Time = ( (initial C voltage - 0.6) * C ) / (sink current + leakage current)
The sink current is approximately 140nA with 5V power supply. Therefore the discharge time for a 200 ohm resistor and 1nF capacitor is approximately 30ms. This means the hibernate will end after approximately 30ms, although the discharge time is highly dependant on the capacitance (of the capacitor and circuit), and so, for example, long pcb tracks and moisture in the air can considerably affect these times.
The capacitor can also be completely replaced by a push-to-make switch (use 1k resistor as R and add another 100k resistor from the top of the switch to V+ to act as a positive voltage pull-up). The switch then acts as a manual 'wake-up' switch. Note that the 1k is essential to prevent a possible short circuit situation (if the switch was pushed whilst the hibernate starts, as it will momentarily make ADC0 an output to 'charge the capacitor').