4.4.2 ECCP - Enhanced CCP

Enhanced Capture/Compare/PWM

4.4.2.1 Introduction

The Enhanced Capture/Compare/PWM module is similar to the standard CCP peripheral but with enhanced PWM capabilities such as provision for two or four output channels, output steering, programmable polarity, programmable dead-band control, and automatic shutdown and restart. Capture, Compare, and single-output PWM functions of the ECCP module are the same as described for the standard CCP module.

4.4.2.2 Supported Device Families

PIC16(L)F193x PIC16(L)F194x PIC12(L)F182x
PIC12(L)F184x PIC16(L)F182x PIC16(L)F184x
PIC18F-K20 PIC18(L)F-K22 PIC18(L)F-K50
PIC18(L)F-K80 PIC18(L)F-K90

4.4.2.3 Required Header Files:


#include "mcc_generated_files/capture/eccp[x].h" or
#include "mcc_generated_files/compare/eccp[x].h" or
#include "mcc_generated_files/pwm/eccp[x].h"
Note: Replace [X] with instance number of selected CCP module

4.4.2.4 Module Documentation

4.4.2.4.1 CAPTURE1

This file contains the API prototypes and other data types for the ECCP1 module.

Module description

This file contains the API prototypes and other data types for the ECCP1 module.

Version: ECCP1 Driver Version 1.0.0
Data structures
  • union CCPR1_PERIOD_REG_T

    Custom data type to hold the low byte, high byte and 16-bit values of the Period register.

Functions
  • static void ECCP1_DefaultCallBack (uint16_t capturedValue)

    Default callback function for the capture interrupt events.

  • void ECCP1_Initialize (void)

    Initializes the ECCP1 module. This is called only once before calling other ECCP1 APIs.

  • void ECCP1_CaptureISR (void)

    Implements the Interrupt Service Routine (ISR) for the capture interrupt.

  • void ECCP1_SetCallBack (void(*customCallBack)(uint16_t))

    Assigns a callback function that will be called from the Capture ISR when a capture interrupt event occurs.

Variables
  • static void(* ECCP1_CallBack )(uint16_t)

    Declares the function pointer for the callback API.

Function Documentation

ECCP1_CaptureISR()

void ECCP1_CaptureISR (void )

Implements the Interrupt Service Routine (ISR) for the capture interrupt.

Parameters:
None.
Returns:

None.

ECCP1_DefaultCallBack()

static void ECCP1_DefaultCallBack (uint16_t capturedValue)[static]

Default callback function for the capture interrupt events.

Parameters:
capturedValue

- 16-bit captured value

Returns:

None.

ECCP1_Initialize()

void ECCP1_Initialize (void )

Initializes the ECCP1 module. This is called only once before calling other ECCP1 APIs.

Parameters:
None.
Returns:

None.

ECCP1_SetCallBack()

void ECCP1_SetCallBack (void(*)(uint16_t) customCallBack)

Assigns a callback function that will be called from the Capture ISR when a capture interrupt event occurs.

Parameters:
(*customCallBack)(uint16_t)

- Function pointer to the new callback

Returns:

None.

Variable Documentation

ECCP1_CallBack

void(* ECCP1_CallBack) (uint16_t)[static]

Declares the function pointer for the callback API.

4.4.2.4.2 COMPARE1

This file contains the API prototypes and other data types for the ECCP1 module.

Module description

This file contains the API prototypes and other data types for the ECCP1 module.

Version: ECCP1 Driver Version 1.0.0
Data structures
  • union CCPR1_PERIOD_REG_T

    Custom data type to hold the low byte, high byte and 16-bit values of the Period register.

Functions
  • void ECCP1_Initialize (void)

    Initializes the ECCP1 module. This is called only once before calling other ECCP1 APIs.

  • void ECCP1_SetCompareCount (uint16_t compareCount)

    Sets the 16-bit compare value.

  • void ECCP1_CompareISR (void)

    Implements the Interrupt Service Routine (ISR) for the compare interrupt.

Function Documentation

ECCP1_CompareISR()

void ECCP1_CompareISR (void )

Implements the Interrupt Service Routine (ISR) for the compare interrupt.

Parameters:
None.
Returns:

None.

ECCP1_Initialize()

void ECCP1_Initialize (void )

Initializes the ECCP1 module. This is called only once before calling other ECCP1 APIs.

Parameters:
None.
Returns:

None.

ECCP1_SetCompareCount()

void ECCP1_SetCompareCount (uint16_t compareCount)

Sets the 16-bit compare value.

Precondition:

ECCP1_Initialize() is already called.

Parameters:
compareCount

- 16-bit unsigned value

Returns:

None.

4.4.2.4.3 PWM1

This file contains the API prototypes for the PWM1 module.

Module description

This file contains the API prototypes for the PWM1 module.

Version: PWM1 Driver Version 1.0.0
Functions
  • void ECCP1_Initialize (void)

    Initializes the ECCP1 module. This is called only once before calling other ECCP1 APIs.

  • void ECCP1_LoadDutyValue (uint16_t dutyValue)

    Loads the 16-bit duty cycle value.

Definition Documentation

EPWM1_Initialize

#define EPWM1_Initialize ECCP1_Initialize

Defines the Custom Name for the ECCP1_Initialize API.

EPWM1_LoadDutyValue

#define EPWM1_LoadDutyValue ECCP1_LoadDutyValue

Defines the Custom Name for the ECCP1_LoadDutyValue API.

Function Documentation

ECCP1_Initialize()

void ECCP1_Initialize (void )

Initializes the ECCP1 module. This is called only once before calling other ECCP1 APIs.

Parameters:
None.
Returns:

None.

ECCP1_LoadDutyValue()

void ECCP1_LoadDutyValue (uint16_t dutyValue)

Loads the 16-bit duty cycle value.

Precondition:

ECCP1_Initialize() is already called.

Parameters:
dutyValue

- 16-bit duty cycle value

Returns:

None.

4.4.2.5 Class Documentation

4.4.2.5.1 CCPR1_PERIOD_REG_T Union Reference

Custom data type to hold the low byte, high byte and 16-bit values of the Period register.

Detailed Description

Custom data type to hold the low byte, high byte and 16-bit values of the Period register.

#include <eccpcapture.h>

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

source/

eccpcapture.h

4.4.2.5.2 CCPR1Reg_tag Union Reference

#include <eccpcapture.h>

Member Data Documentation

The documentation for this union was generated from the following files:

source/

eccpcapture.h

source/

eccpcompare.h

@1

struct { ... }

@3

struct { ... }

@5

struct { ... }

@7

struct { ... }

ccpr1_16Bit

uint16_t ccpr1_16Bit

CCPR1 16-bit.

ccpr1h

uint8_t ccpr1h

CCPR1H high byte.

ccpr1l

uint8_t ccpr1l

CCPR1L low byte.

4.4.2.6 File Documentation

4.4.2.6.1 source/eccpcapture.c File Reference

#include <xc.h>
#include "../eccp1.h"

Functions

  • static void ECCP1_DefaultCallBack (uint16_t capturedValue)

    Default callback function for the capture interrupt events.

  • void ECCP1_Initialize (void)

    Initializes the ECCP1 module. This is called only once before calling other ECCP1 APIs.

  • void ECCP1_CaptureISR (void)

    Implements the Interrupt Service Routine (ISR) for the capture interrupt.

  • void ECCP1_SetCallBack (void(*customCallBack)(uint16_t))

    Assigns a callback function that will be called from the Capture ISR when a capture interrupt event occurs.

Variables

  • static void(* ECCP1_CallBack )(uint16_t)

    Declares the function pointer for the callback API.

4.4.2.6.2 source/eccpcapture.h File Reference

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

Functions

  • void ECCP1_Initialize (void)

    Initializes the ECCP1 module. This is called only once before calling other ECCP1 APIs.

  • void ECCP1_CaptureISR (void)

    Implements the Interrupt Service Routine (ISR) for the capture interrupt.

  • void ECCP1_SetCallBack (void(*customCallBack)(uint16_t))

    Assigns a callback function that will be called from the Capture ISR when a capture interrupt event occurs.

Typedef Documentation

CCPR1_PERIOD_REG_T

typedef union CCPR1Reg_tag CCPR1_PERIOD_REG_T

4.4.2.6.3 source/eccpcompare.c File Reference

#include <xc.h>
#include "../eccp1.h"

Functions

  • void ECCP1_Initialize (void)

    Initializes the ECCP1 module. This is called only once before calling other ECCP1 APIs.

  • void ECCP1_SetCompareCount (uint16_t compareCount)

    Sets the 16-bit compare value.

  • void ECCP1_CompareISR (void)

    Implements the Interrupt Service Routine (ISR) for the compare interrupt.

4.4.2.6.4 source/eccpcompare.h File Reference

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

Functions

  • void ECCP1_Initialize (void)

    Initializes the ECCP1 module. This is called only once before calling other ECCP1 APIs.

  • void ECCP1_SetCompareCount (uint16_t compareCount)

    Sets the 16-bit compare value.

  • void ECCP1_CompareISR (void)

    Implements the Interrupt Service Routine (ISR) for the compare interrupt.

Typedef Documentation

CCPR1_PERIOD_REG_T

typedef union CCPR1Reg_tag CCPR1_PERIOD_REG_T

4.4.2.6.5 source/eccppwm.c File Reference

#include <xc.h>
#include "../eccp1.h"

Functions

  • void ECCP1_Initialize (void)

    Initializes the ECCP1 module. This is called only once before calling other ECCP1 APIs.

  • void ECCP1_LoadDutyValue (uint16_t dutyValue)

    Loads the 16-bit duty cycle value.

Macro Definition Documentation

PWM1_INITIALIZE_DUTY_VALUE

#define PWM1_INITIALIZE_DUTY_VALUE 0

4.4.2.6.6 source/eccppwm.h File Reference

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

Functions

  • void ECCP1_Initialize (void)

    Initializes the ECCP1 module. This is called only once before calling other ECCP1 APIs.

  • void ECCP1_LoadDutyValue (uint16_t dutyValue)

    Loads the 16-bit duty cycle value.