AM64x MCU+ SDK  08.02.00
ECAP

The eCAP driver provides API to configure eCAP module. Below are the high level features supported by the driver.

Features Supported

  • Configuration of timestamp capture event
  • Configuration of one-shot/continuous mode
  • Configuration of independent edge polarity (rising / falling edge) selection for all 4 capture events
  • Configuration of interrupt on any of the 4 capture events
  • Configuration of input signal prescaling
  • Configuration of mode to aPWM when not used in capture mode

SysConfig Features

Note
It is strongly recommend to use SysConfig where it is available instead of using direct SW API calls. This will help simplify the SW application and also catch common mistakes early in the development cycle.

SysConfig can be used to configure below parameters apart from common configuration like Clock, MPU, RAT and others.

  • ECAP instances and pin mux configurations.

Features NOT Supported

NA

Important Usage Guidelines

NA

Example Usage

Include the below file to access the APIs

#include <drivers/ecap.h>

ECAP Interrupt Registration

int32_t status = SystemP_SUCCESS;
HwiP_Params hwiPrms;
/* Register interrupt */
HwiP_Params_init(&hwiPrms);
hwiPrms.intNum = CONFIG_ECAP0_INTR;
hwiPrms.callback = &App_ecapIntrISR;
hwiPrms.isPulse = CONFIG_ECAP0_INTR_IS_PULSE;
status = HwiP_construct(&gEcapHwiObject, &hwiPrms);

ECAP Operating Mode Configuration

/* Enable capture mode */

ECAP One Shot Mode Configuration

/* One shot mode, stop capture at event 4 */

ECAP Capture Event Polarity Configuration

/* Set polarity of the events to rising, falling, rising, falling edge */

ECAP Interrupt Service Routine

/* Clear Ecap Interrupt. */
ECAP_intrStatusClear(gEcapBaseAddr, ECAP_INT_ALL);
/* Clear Global Interrupt Flag. */
ECAP_globalIntrClear(gEcapBaseAddr);
SemaphoreP_post(&gEcapSyncSemObject);

ECAP Interrupt De-Registration

HwiP_destruct(&gEcapHwiObject);

API

APIs for ECAP

ECAP_CAPTURE_MODE
#define ECAP_CAPTURE_MODE
Capture Mode.
Definition: ecap/v0/ecap.h:74
ECAP_captureEvtPolarityConfig
void ECAP_captureEvtPolarityConfig(uint32_t baseAddr, uint32_t capEvt1pol, uint32_t capEvt2pol, uint32_t capEvt3pol, uint32_t capEvt4pol)
This function configures Capture Event polarity.
ECAP_CAPTURE_EVENT_FALLING
#define ECAP_CAPTURE_EVENT_FALLING
Capture Event Falling Edge.
Definition: ecap/v0/ecap.h:194
HwiP_destruct
void HwiP_destruct(HwiP_Object *obj)
Cleanup, delete, destruct a Hwi object.
ECAP_intrStatusClear
void ECAP_intrStatusClear(uint32_t baseAddr, uint32_t flag)
This function clears of the status specified interrupts.
HwiP_Params
Parameters passed during HwiP_construct.
Definition: HwiP.h:72
ecap.h
ECAP_operatingModeSelect
void ECAP_operatingModeSelect(uint32_t baseAddr, uint32_t modeSelect)
This function configures ecapture module to operate in capture mode or in APWM mode.
ECAP_globalIntrClear
void ECAP_globalIntrClear(uint32_t baseAddr)
This function clears global interrupt and enables the generation of interrupts if any of the event in...
HwiP_construct
int32_t HwiP_construct(HwiP_Object *obj, HwiP_Params *params)
Create a Hwi object.
HwiP_Params_init
void HwiP_Params_init(HwiP_Params *params)
Set default values to HwiP_Params.
ECAP_oneShotModeConfig
void ECAP_oneShotModeConfig(uint32_t baseAddr, uint32_t stopVal)
This function configures ECAP to One-shot mode and also stop value for this mode.
ECAP_CAPTURE_EVENT4_STOP
#define ECAP_CAPTURE_EVENT4_STOP
Stop capture after event 4.
Definition: ecap/v0/ecap.h:106
SystemP_SUCCESS
#define SystemP_SUCCESS
Return status when the API execution was successful.
Definition: SystemP.h:56
HwiP_Params::isPulse
uint8_t isPulse
Definition: HwiP.h:80
HwiP_Params::callback
HwiP_FxnCallback callback
Definition: HwiP.h:75
ECAP_CAPTURE_EVENT_RISING
#define ECAP_CAPTURE_EVENT_RISING
Capture Event Rising Edge.
Definition: ecap/v0/ecap.h:192
SemaphoreP_post
void SemaphoreP_post(SemaphoreP_Object *obj)
Post a semaphore object or unlock a mutex.
DebugP_assert
#define DebugP_assert(expression)
Function to call for assert check.
Definition: DebugP.h:159
HwiP_Params::intNum
uint32_t intNum
Definition: HwiP.h:74