3.12 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.

3.12.1 Module Documentation

3.12.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.

3.12.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
Definitions
Functions
Variables
  • 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.

3.12.1.1.2 Definition Documentation

Input_Capture2_DataRead

#define Input_Capture2_DataRead SCCP2_InputCapture_DataRead

This macro defines the Custom Name for SCCP2_InputCapture_DataRead API.

Input_Capture2_Deinitialize

#define Input_Capture2_Deinitialize SCCP2_InputCapture_Deinitialize

This macro defines the Custom Name for SCCP2_InputCapture_Deinitialize API.

Input_Capture2_HasBufferOverflowed

#define Input_Capture2_HasBufferOverflowed SCCP2_InputCapture_HasBufferOverflowed

This macro defines the Custom Name for SCCP2_InputCapture_HasBufferOverflowed API.

Input_Capture2_Initialize

#define Input_Capture2_Initialize SCCP2_InputCapture_Initialize

This macro defines the Custom Name for SCCP2_InputCapture_Initialize API.

Input_Capture2_InputCapture_CallbackRegister

#define Input_Capture2_InputCapture_CallbackRegister SCCP2_InputCapture_CallbackRegister

This macro defines the Custom Name for SCCP2_InputCapture_CallbackRegister API.

Input_Capture2_IsBufferEmpty

#define Input_Capture2_IsBufferEmpty SCCP2_InputCapture_IsBufferEmpty

This macro defines the Custom Name for SCCP2_InputCapture_IsBufferEmpty API.

Input_Capture2_OverflowFlagClear

#define Input_Capture2_OverflowFlagClear SCCP2_InputCapture_OverflowFlagClear

This macro defines the Custom Name for SCCP2_InputCapture_OverflowFlagClear API.

Input_Capture2_Start

#define Input_Capture2_Start SCCP2_InputCapture_Start

This macro defines the Custom Name for SCCP2_InputCapture_Start API.

Input_Capture2_Stop

#define Input_Capture2_Stop SCCP2_InputCapture_Stop

This macro defines the Custom Name for SCCP2_InputCapture_Stop API.

Input_Capture2_Tasks

#define Input_Capture2_Tasks SCCP2_InputCapture_Tasks

This macro defines the Custom Name for SCCP2_InputCapture_Tasks API.

3.12.1.1.3 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  

3.12.1.1.4 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.

3.12.2 Data Structure Documentation

3.12.2.1 INPUT_CAPTURE_INTERFACE Struct Reference

Structure containing the function pointers of MCCP-InputCapture driver.

3.12.2.1.1 Detailed Description

Structure containing the function pointers of MCCP-InputCapture driver.

#include <input_capture_interface.h>

Data Fields
  • 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.

3.12.2.1.2 Field 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)

3.12.3 File Documentation

3.12.3.1 source/input_capture_interface.h File Reference

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

3.12.3.1.1 Data structures

3.12.3.1.2 Detailed Description

MCCP-InputCapture Generated Driver Interface Header File

3.12.3.2 source/sccp2.h File Reference

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

3.12.3.2.1 Functions

3.12.3.2.2 Macros

3.12.3.2.3 Variables

  • 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.

3.12.3.2.4 Macro Definition Documentation

SCCP2_CAPTURE_TIMER_FREQUENCY

#define SCCP2_CAPTURE_TIMER_FREQUENCY 4000000UL

This macro is used to read the Input Capture timer frequency (in Hz) for SCCP2 instance.