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.

Manual Wakeup

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').

Applies To:
28X1, 40X1
See Also:
Related Create:

    Flash an LED

    Toggle an LED on and off every 50ms while conserving

    Code Example:
    main:	toggle 1	; toggle state of output 1
    	hibernate 50	; hibernate after charging cap for 50ms
    	disablebod	; turn bod off
    	goto main	; loop back to start
    Copy Code Submit an Example

    Submit Your Own Code!

    You must be logged in to submit code examples. Login now.


    • Login to leave a comment.