1.1.5 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
Functions
Name | Description |
---|---|
HTMx_Initialize | Initializes given instance of HTM timer peripheral. |
HTMx_PeriodGet | Returns the period value for the HTM timer |
HTMx_PeriodSet | Sets the time period and starts the HTM timer |
HTMx_ResolutionSet | Sets the resolution of the HTM timer |
HTMx_CountGet | Returns the timer counter value for the HTM timer |
HTMx_CallbackRegister | Allows application to register a callback with the PLIB |
Data types and constants
Name | Type | Description |
---|---|---|
HTM_TMR_RESOLUTION | Macro | Defines the macros associated with Hibernation timer resolution |
HTM_TMR_CALLBACK | Typedef | Defines the data type and function signature for the HTM timer peripheral callback function. |