Jump to main content

##

# 3.1.12 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

Functions

Name | Description
--- | ---
TIMER32_x_Initialize | Initializes given instance of TIMER32 timer peripheral.
TIMER32_x_PeriodHasExpired | Returns the timer interrupt status
TIMER32_x_PreLoadCountGet | Returns the timer pre-load value
TIMER32_x_PreLoadCountSet | Sets the timer pre-load value
TIMER32_x_PrescalerSet | Selects the divider value for the clock source for the Timer32 peripheral.
TIMER32_x_Reload | Reloads the timer counter
TIMER32_x_Start | Starts the timer counter
TIMER32_x_Stop | Stops the timer counter
TIMER32_x_FrequencyGet | Returns the input frequency of the Timer32 peripheral
TIMER32_x_CounterSet | Sets the timer counter
TIMER32_x_CounterGet | Returns the timer counter value
TIMER32_x_CallbackRegister | Allows application to register a callback with the PLIB
TIMER32_x_AutoReStartEnable | Enable auto re-start of the timer
TIMER32_x_AutoReStartDisable | Disable auto re-start of the timer

Data types and constants

Name | Type | Description
--- | --- | ---
TMR32_CALLBACK | Typedef | Defines the data type and function signature for the timer peripheral callback function.