2.53 HTM (Hibernation Timer)

The Hibernation Timer can generate a wake event to the Embedded Controller (EC) when it is in a hibernation mode.

This block supports wake events up to 2 hours in duration. The Hibernation Timer is a 16-bit binary count-down timer that can be programmed in 30.5μs and 0.125 second increments for period ranges of 30.5μs to 2s or 0.125s to 136.5 minutes, respectively. Writing a non-zero value to this register starts the counter from that value. A wake-up interrupt is generated when the count reaches zero.

Using the Library

The below example generates periodic timeout using the Hibernation peripheral. A callback is registered with the Hibernation timer peripheral. In the callback an LED is toggled and the timer period is re-configured to generate another timeout after 1 second thereby resulting in a periodic toggling of LED every 1 second.
void htm_timeout_callback(uintptr_t context)
{
    LED0_Toggle();
    
    HTM0_PeriodSet(32768);
}

int main ( void )
{
    /* Initialize all modules */
    SYS_Initialize ( NULL );
    
    HTM0_CallbackRegister(htm_timeout_callback, 0);

    while ( true )
    {
        /* Maintain state machines of all polled MPLAB Harmony modules. */
        SYS_Tasks ( );
    }

    /* Execution should not come here during normal operation */

    return ( EXIT_FAILURE );
}

Library Interface

HTM peripheral library provides the following interfaces:

Functions

NameDescription
HTMx_InitializeInitializes given instance of HTM timer peripheral.
HTMx_PeriodGetReturns the period value for the HTM timer
HTMx_PeriodSetSets the time period and starts the HTM timer
HTMx_ResolutionSetSets the resolution of the HTM timer
HTMx_CountGetReturns the timer counter value for the HTM timer
HTMx_CallbackRegisterAllows application to register a callback with the PLIB

Data types and constants

NameTypeDescription
HTM_TMR_RESOLUTIONMacroDefines the macros associated with Hibernation timer resolution
HTM_TMR_CALLBACKTypedefDefines the data type and function signature for the HTM timer peripheral callback function.
Note: Not all APIs maybe implemented. See the specific device family section for available APIs.