2.14 Input Capture Driver

2.14.1 Introduction

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.2 Module Documentation

2.14.2.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.2.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.

2.14.2.1.1.1 Data structures
2.14.2.1.1.2 Functions

2.14.2.1.2 Function Documentation

2.14.2.1.2.1 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

2.14.2.1.2.2 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

2.14.2.1.2.3 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

2.14.2.1.2.4 SCCP2_InputCapture_Deinitialize()

void SCCP2_InputCapture_Deinitialize (void )

Deinitializes the SCCP2-InputCapture to POR values.

Parameters:
none
Returns:

none

2.14.2.1.2.5 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

2.14.2.1.2.6 SCCP2_InputCapture_Initialize()

void SCCP2_InputCapture_Initialize (void )

Initializes the SCCP2-InputCapture module.

Parameters:
none
Returns:

none

2.14.2.1.2.7 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

2.14.2.1.2.8 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

2.14.2.1.2.9 SCCP2_InputCapture_Start()

void SCCP2_InputCapture_Start (void )

Starts the InputCapture operation.

Precondition:

SCCP2_InputCapture_Initialize must be called

Parameters:
none
Returns:

none

2.14.2.1.2.10 SCCP2_InputCapture_Stop()

void SCCP2_InputCapture_Stop (void )

Stops the InputCapture operation.

Precondition:

SCCP2_InputCapture_Initialize must be called

Parameters:
none
Returns:

none

2.14.2.1.2.11 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.2.1.3 Variable Documentation

2.14.2.1.3.1 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.3 Class Documentation

2.14.3.1 INPUT_CAPTURE_INTERFACE Struct Reference

Structure containing the function pointers of MCCP-InputCapture driver.

2.14.3.1.1 Detailed Description

Structure containing the function pointers of MCCP-InputCapture driver.

#include <input_capture_interface.h>

2.14.3.1.1.1 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.3.1.2 Member Data Documentation

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

source/

input_capture_interface.h

2.14.3.1.2.1 DataRead

uint32_t(* DataRead) (void)

Pointer to SCCPx_InputCapture_DataRead e.g. SCCP1_InputCapture_DataRead.

2.14.3.1.2.2 Deinitialize

void(* Deinitialize) (void)

Pointer to SCCPx_InputCapture_Deinitialize e.g. SCCP1_InputCapture_Deinitialize.

2.14.3.1.2.3 HasBufferOverflowed

bool(* HasBufferOverflowed) (void)

Pointer to SCCPx_InputCapture_HasBufferOverflowed e.g. SCCP1_InputCapture_HasBufferOverflowed.

2.14.3.1.2.4 Initialize

void(* Initialize) (void)

Pointer to SCCPx_InputCapture_Initialize e.g. SCCP1_InputCapture_Initialize.

2.14.3.1.2.5 InputCapture_CallbackRegister

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

Pointer to SCCPx_InputCapture_CallbackRegister e.g. SCCP1_InputCapture_CallbackRegister.

2.14.3.1.2.6 IsBufferEmpty

bool(* IsBufferEmpty) (void)

Pointer to SCCPx_InputCapture_IsBufferEmpty e.g. SCCP1_InputCapture_IsBufferEmpty.

2.14.3.1.2.7 OverflowFlagClear

void(* OverflowFlagClear) (void)

Pointer to SCCPx_InputCapture_OverflowFlagClear e.g. SCCP1_InputCapture_OverflowFlagClear.

2.14.3.1.2.8 Start

void(* Start) (void)

Pointer to SCCPx_InputCapture_Start e.g. SCCP1_InputCapture_Start.

2.14.3.1.2.9 Stop

void(* Stop) (void)

Pointer to SCCPx_InputCapture_Stop e.g. SCCP1_InputCapture_Stop.

2.14.3.1.2.10 Tasks

void(* Tasks) (void)

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

2.14.4 File Documentation

2.14.4.1 source/input_capture_interface.h File Reference

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

2.14.4.1.1 Data structures

2.14.4.1.2 Detailed Description

MCCP-InputCapture Generated Driver Interface Header File

2.14.4.2 source/sccp2.h File Reference

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

2.14.4.2.1 Functions