2.14 Input Capture Driver

Overview

Input Capture is used to capture a timer value from an independent timer base on the occurrence of an event on an input pin. This is useful in applications requiring frequency (time period) and pulse measurement.

Features

  • User configurable capture mode like any Edge Detect or Every Raising Edge or Every Falling Edge.
  • Independent timer period depends on the clock source selected from the PLIB.
  • In sync operation, the timer Reset or clear occurs when the input selected by SYNC is asserted,in trigger operation, the timer is held in Reset until the input selected by trigger is asserted.

2.14.1 Module Documentation

2.14.1.1 Input Capture Driver

Input Capture Driver is a 16-bit timer or 32-bit timer that is useful in applications requiring frequency (time period) and pulse measurement using dsPIC MCUs.

2.14.1.1.1 Module description

Input Capture Driver is a 16-bit timer or 32-bit timer that is useful in applications requiring frequency (time period) and pulse measurement using dsPIC MCUs.

Data structures
Functions

2.14.1.1.2 Function Documentation

SCCP2_InputCapture_Callback()

void SCCP2_InputCapture_Callback (void )

This is the default callback with weak attribute. The user can override and implement the default callback without weak attribute or can register a custom callback function using SCCP2_InputCaptureCallbackRegister.

Parameters:
none
Returns:

none

SCCP2_InputCapture_CallbackRegister()

void SCCP2_InputCapture_CallbackRegister (void(*)(void) handler)

This function can be used to override default callback and to define custom callback for SCCP2 InputCapture event.

Parameters:
in handler

- Address of the callback function

Returns:

none

SCCP2_InputCapture_DataRead()

uint32_t SCCP2_InputCapture_DataRead (void )

Reads the captured value.

Precondition:

SCCP2_InputCapture_Initialize must be called.

Parameters:
none
Returns:

Returns the captured value

SCCP2_InputCapture_Deinitialize()

void SCCP2_InputCapture_Deinitialize (void )

Deinitializes the SCCP2-InputCapture to POR values.

Parameters:
none
Returns:

none

SCCP2_InputCapture_HasBufferOverflowed()

bool SCCP2_InputCapture_HasBufferOverflowed (void )

Returns the buffer overflow status.

Precondition:

SCCP2_InputCapture_Initialize must be called

Parameters:
none
Returns:

true - input capture buffer has overflowed

false - input capture buffer has not overflowed

SCCP2_InputCapture_Initialize()

void SCCP2_InputCapture_Initialize (void )

Initializes the SCCP2-InputCapture module.

Parameters:
none
Returns:

none

SCCP2_InputCapture_IsBufferEmpty()

bool SCCP2_InputCapture_IsBufferEmpty (void )

Returns the buffer empty status.

Precondition:

SCCP2_InputCapture_Initialize must be called

Parameters:
none
Returns:

true - input capture buffer is empty

false - input capture buffer is not empty

SCCP2_InputCapture_OverflowFlagClear()

void SCCP2_InputCapture_OverflowFlagClear (void )

Clears the buffer overflow status flag.

Precondition:

SCCP2_InputCapture_Initialize must be called

Parameters:
none
Returns:

none

SCCP2_InputCapture_Start()

void SCCP2_InputCapture_Start (void )

Starts the InputCapture operation.

Precondition:

SCCP2_InputCapture_Initialize must be called

Parameters:
none
Returns:

none

SCCP2_InputCapture_Stop()

void SCCP2_InputCapture_Stop (void )

Stops the InputCapture operation.

Precondition:

SCCP2_InputCapture_Initialize must be called

Parameters:
none
Returns:

none

SCCP2_InputCapture_Tasks()

void SCCP2_InputCapture_Tasks (void )

This function is used to implement the tasks for polled implementations.

Precondition:

SCCP2_InputCapture_Initialize must be called

Parameters:
none
Returns:

none

2.14.1.1.3 Variable Documentation

Input_Capture2

const struct INPUT_CAPTURE_INTERFACE Input_Capture2

Structure object of type INPUT_CAPTURE_INTERFACE with the custom name given by the user in the Melody Driver User interface.

The default name e.g. Input_Capture1 can be changed by the user in the INPUT_CAPTURE user interface. This allows defining a structure with application specific name using the 'Custom Name' field. Application specific name allows the API Portability.

2.14.2 Class Documentation

2.14.2.1 INPUT_CAPTURE_INTERFACE Struct Reference

Structure containing the function pointers of MCCP-InputCapture driver.

2.14.2.1.1 Detailed Description

Structure containing the function pointers of MCCP-InputCapture driver.

#include <input_capture_interface.h>

Public Attributes
  • void(* Initialize )(void)

    Pointer to SCCPx_InputCapture_Initialize e.g. SCCP1_InputCapture_Initialize.

  • void(* Deinitialize )(void)

    Pointer to SCCPx_InputCapture_Deinitialize e.g. SCCP1_InputCapture_Deinitialize.

  • void(* Start )(void)

    Pointer to SCCPx_InputCapture_Start e.g. SCCP1_InputCapture_Start.

  • void(* Stop )(void)

    Pointer to SCCPx_InputCapture_Stop e.g. SCCP1_InputCapture_Stop.

  • void(* InputCapture_CallbackRegister )(void(*CallbackHandler)(void))

    Pointer to SCCPx_InputCapture_CallbackRegister e.g. SCCP1_InputCapture_CallbackRegister.

  • void(* Tasks )(void)

    Pointer to SCCPx_InputCapture_Tasks e.g. SCCP1_InputCapture_Tasks (Supported only in polling mode)

  • uint32_t(* DataRead )(void)

    Pointer to SCCPx_InputCapture_DataRead e.g. SCCP1_InputCapture_DataRead.

  • bool(* HasBufferOverflowed )(void)

    Pointer to SCCPx_InputCapture_HasBufferOverflowed e.g. SCCP1_InputCapture_HasBufferOverflowed.

  • bool(* IsBufferEmpty )(void)

    Pointer to SCCPx_InputCapture_IsBufferEmpty e.g. SCCP1_InputCapture_IsBufferEmpty.

  • void(* OverflowFlagClear )(void)

    Pointer to SCCPx_InputCapture_OverflowFlagClear e.g. SCCP1_InputCapture_OverflowFlagClear.

2.14.2.1.2 Member Data Documentation

The documentation for this struct was generated from the following file:

source/

input_capture_interface.h

DataRead

uint32_t(* DataRead) (void)

Pointer to SCCPx_InputCapture_DataRead e.g. SCCP1_InputCapture_DataRead.

Deinitialize

void(* Deinitialize) (void)

Pointer to SCCPx_InputCapture_Deinitialize e.g. SCCP1_InputCapture_Deinitialize.

HasBufferOverflowed

bool(* HasBufferOverflowed) (void)

Pointer to SCCPx_InputCapture_HasBufferOverflowed e.g. SCCP1_InputCapture_HasBufferOverflowed.

Initialize

void(* Initialize) (void)

Pointer to SCCPx_InputCapture_Initialize e.g. SCCP1_InputCapture_Initialize.

InputCapture_CallbackRegister

void(* InputCapture_CallbackRegister) (void(*CallbackHandler)(void))

Pointer to SCCPx_InputCapture_CallbackRegister e.g. SCCP1_InputCapture_CallbackRegister.

IsBufferEmpty

bool(* IsBufferEmpty) (void)

Pointer to SCCPx_InputCapture_IsBufferEmpty e.g. SCCP1_InputCapture_IsBufferEmpty.

OverflowFlagClear

void(* OverflowFlagClear) (void)

Pointer to SCCPx_InputCapture_OverflowFlagClear e.g. SCCP1_InputCapture_OverflowFlagClear.

Start

void(* Start) (void)

Pointer to SCCPx_InputCapture_Start e.g. SCCP1_InputCapture_Start.

Stop

void(* Stop) (void)

Pointer to SCCPx_InputCapture_Stop e.g. SCCP1_InputCapture_Stop.

Tasks

void(* Tasks) (void)

Pointer to SCCPx_InputCapture_Tasks e.g. SCCP1_InputCapture_Tasks (Supported only in polling mode)

2.14.3 File Documentation

2.14.3.1 source/input_capture_interface.h File Reference

#include <stdbool.h>
#include <stdint.h>

2.14.3.1.1 Data structures

2.14.3.1.2 Detailed Description

MCCP-InputCapture Generated Driver Interface Header File

2.14.3.2 source/sccp2.h File Reference

#include <stdbool.h>
#include <stdint.h>
#include "input_capture_interface.h"

2.14.3.2.1 Functions