Jump to main content

##

# 2.122.12 TIMER32_x_CallbackRegister Function

## C

    /* x = Timer32 instance number */

    void TIMER32_x_CallbackRegister(TMR32_CALLBACK callback_fn, uintptr_t context )

## Summary

Allows application to register a callback with the PLIB

## Description

This function sets the pointer to a client/application function to be called "back" when the Timer expires. It also passes a context value (usually a pointer to a context structure) that is passed into the function when it is called. The specified callback function will be called from the peripheral interrupt context. The callback should be registered before starting the timer.

## Precondition

TIMER32_x_Initialize() function must have been called first.

## Parameters

Param | Description
--- | ---
callback_fn | A pointer to a function with a calling signature defined by the TMR32_CALLBACK data type. Setting this to NULL disables the callback feature.
context | A value (usually a pointer) which is passed (unused) into the function identified by the callback parameter

## Returns

None

## Example

    void tmr32_callback(uint32_t status, uintptr_t context)
    {
        /* Handle timer expiry */
    }

    TIMER32_0_CallbackRegister(tmr32_callback, 0);

## Remarks

None