2.115 32-bit Timer

This timer block offers a simple mechanism for firmware to maintain a time base.

Using the Library

void tmr32_callback(uint32_t status, uintptr_t context)
{
    LED0_Toggle();
}

int main ( void )
{
    /* Initialize all modules */
    SYS_Initialize ( NULL );
    
    TIMER32_0_CallbackRegister(tmr32_callback, 0);
    
    TIMER32_0_Start();

    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

32-bit Timer peripheral library provides the following interfaces:

Functions

NameDescription
TIMER32_x_InitializeInitializes given instance of TIMER32 timer peripheral.
TIMER32_x_PeriodHasExpiredReturns the timer interrupt status
TIMER32_x_PreLoadCountGetReturns the timer pre-load value
TIMER32_x_PreLoadCountSetSets the timer pre-load value
TIMER32_x_PrescalerSetSelects the divider value for the clock source for the Timer32 peripheral.
TIMER32_x_ReloadReloads the timer counter
TIMER32_x_StartStarts the timer counter
TIMER32_x_StopStops the timer counter
TIMER32_x_FrequencyGetReturns the input frequency of the Timer32 peripheral
TIMER32_x_CounterSetSets the timer counter
TIMER32_x_CounterGetReturns the timer counter value
TIMER32_x_CallbackRegisterAllows application to register a callback with the PLIB
TIMER32_x_AutoReStartEnableEnable auto re-start of the timer
TIMER32_x_AutoReStartDisableDisable auto re-start of the timer

Data types and constants

NameTypeDescription
TMR32_CALLBACKTypedefDefines the data type and function signature for the timer peripheral callback function.
Note: Not all APIs maybe implemented. See the specific device family section for available APIs.