AM64x MCU+ SDK  08.02.00

Introduction

This module contains APIs to program and use the ECAP module.

Files

file  ecap/v0/ecap.h
 This file contains the function prototypes for the device abstraction layer for ECAP. It also contains some related macro definitions and some files to be included.
 

Functions

void ECAP_captureLoadingEnable (uint32_t baseAddr)
 This function enables capture loading. More...
 
void ECAP_captureLoadingDisable (uint32_t baseAddr)
 This function disables capture loading. More...
 
void ECAP_prescaleConfig (uint32_t baseAddr, uint32_t prescale)
 This function configures prescale value. More...
 
void ECAP_operatingModeSelect (uint32_t baseAddr, uint32_t modeSelect)
 This function configures ecapture module to operate in capture mode or in APWM mode. More...
 
uint32_t ECAP_timeStampRead (uint32_t baseAddr, uint32_t capEvtFlag)
 This function returns time-stamp for a given capture event. More...
 
void ECAP_counterConfig (uint32_t baseAddr, uint32_t countVal)
 This function configures the counter register which is used as Capture Time base. More...
 
void ECAP_captureEvtPolarityConfig (uint32_t baseAddr, uint32_t capEvt1pol, uint32_t capEvt2pol, uint32_t capEvt3pol, uint32_t capEvt4pol)
 This function configures Capture Event polarity. More...
 
void ECAP_captureEvtCntrRstConfig (uint32_t baseAddr, uint32_t counterRst1, uint32_t counterRst2, uint32_t counterRst3, uint32_t counterRst4)
 This function enables reset of the counters upon Capture Events. More...
 
void ECAP_continousModeConfig (uint32_t baseAddr)
 This function configures ECAP to Continuous mode. More...
 
void ECAP_oneShotModeConfig (uint32_t baseAddr, uint32_t stopVal)
 This function configures ECAP to One-shot mode and also stop value for this mode. More...
 
void ECAP_oneShotReArm (uint32_t baseAddr)
 This function configures ECAP to One-Short Re-arming. More...
 
void ECAP_APWM_polarityConfig (uint32_t baseAddr, uint32_t flag)
 This function configures output polarity for APWM output. More...
 
void ECAP_counterControl (uint32_t baseAddr, uint32_t flag)
 This function configures counter to stop or free running based on its input argument flag. More...
 
void ECAP_syncInOutSelect (uint32_t baseAddr, uint32_t syncIn, uint32_t syncOut)
 This function configures Sync-In and Sync-Out. More...
 
void ECAP_APWM_captureConfig (uint32_t baseAddr, uint32_t compareVal, uint32_t periodVal)
 When ECAP module is configured in APWM mode capture 1 and capture 2 registers are used as period and compare register.This function configures compare and period values to this register. More...
 
void ECAP_APWM_shadowCaptureConfig (uint32_t baseAddr, uint32_t compareVal, uint32_t periodVal)
 This function configures the Shadow register. More...
 
void ECAP_counterPhaseValConfig (uint32_t baseAddr, uint32_t cntPhaseVal)
 This function configures the counter phase value. More...
 
void ECAP_globalIntrClear (uint32_t baseAddr)
 This function clears global interrupt and enables the generation of interrupts if any of the event interrupt are enabled and corresponding event interrupt flag is set. More...
 
void ECAP_intrEnable (uint32_t baseAddr, uint32_t flag)
 This function enables the specified interrupts. More...
 
void ECAP_intrDisable (uint32_t baseAddr, uint32_t flag)
 This function disables the specified interrupts. More...
 
uint32_t ECAP_getIntrStatus (uint32_t baseAddr, uint32_t flag)
 This function returns the status specified interrupts. More...
 
void ECAP_intrStatusClear (uint32_t baseAddr, uint32_t flag)
 This function clears of the status specified interrupts. More...
 
uint32_t ECAP_peripheralIdGet (uint32_t baseAddr)
 This function returns the peripheral ID. More...
 

ECAP Operating Mode

#define ECAP_CAPTURE_MODE   (0U)
 Capture Mode. More...
 
#define ECAP_APWM_MODE   (1U)
 Auxiliary PWM Mode. More...
 

ECAP time stamp capture on event

#define ECAP_CAPTURE_EVENT_1   ((uint32_t)0x08U)
 Time stamp capture on event 1. More...
 
#define ECAP_CAPTURE_EVENT_2   ((uint32_t)0x0cU)
 Time stamp capture on event 2. More...
 
#define ECAP_CAPTURE_EVENT_3   ((uint32_t)0x10U)
 Time stamp capture on event 3. More...
 
#define ECAP_CAPTURE_EVENT_4   ((uint32_t)0x14U)
 Time stamp capture on event 4. More...
 

ECAP stop capture on event

#define ECAP_CAPTURE_EVENT1_STOP   ((uint32_t)0x00U)
 Stop capture after event 1. More...
 
#define ECAP_CAPTURE_EVENT2_STOP   ((uint32_t)0x01U)
 Stop capture after event 2. More...
 
#define ECAP_CAPTURE_EVENT3_STOP   ((uint32_t)0x02U)
 Stop capture after event 3. More...
 
#define ECAP_CAPTURE_EVENT4_STOP   ((uint32_t)0x03U)
 Stop capture after event 4. More...
 

ECAP APWM Output Polarity

#define ECAP_APWM_ACTIVE_HIGH   (0U)
 Output Polarity HIGH. More...
 
#define ECAP_APWM_ACTIVE_LOW   (1U)
 Output Polarity LOW. More...
 

ECAP Counter Mode

#define ECAP_COUNTER_STOP   (0U)
 Counter Mode Stop. More...
 
#define ECAP_COUNTER_FREE_RUNNING   (1U)
 Counter Mode Free Running. More...
 

ECAP Counter SyncIn Mode

#define ECAP_SYNC_IN_DISABLE   ((uint32_t)0U)
 Disable SyncIn option. More...
 
#define ECAP_ENABLE_COUNTER   ((uint32_t)1U)
 Enable Counter to be loaded from the ECAP_CNTPHS register upon SYNCI signal. More...
 

ECAP Counter SyncOut Mode

#define ECAP_SYNC_IN   ((uint32_t)0x0U)
 Select SyncIn event to be the SyncOut signal. More...
 
#define ECAP_PRD_EQ   ((uint32_t)0x1U)
 Select PRD event to be the SyncOut signal. More...
 
#define ECAP_SYNC_OUT_DISABLE   ((uint32_t)0x2U)
 Disable SyncOut Signal. More...
 

ECAP Interrupt Sources

#define ECAP_CEVT1_INT   (ECAP_ECEINT_CEVT1)
 Capture Event 1 Interrupt Enable. More...
 
#define ECAP_CEVT2_INT   (ECAP_ECEINT_CEVT2)
 Capture Event 2 Interrupt Enable. More...
 
#define ECAP_CEVT3_INT   (ECAP_ECEINT_CEVT3)
 Capture Event 3 Interrupt Enable. More...
 
#define ECAP_CEVT4_INT   (ECAP_ECEINT_CEVT4)
 Capture Event 4 Interrupt Enable. More...
 
#define ECAP_CNTOVF_INT   (ECAP_ECEINT_CTROVF)
 Counter Overflow Interrupt Enable. More...
 
#define ECAP_PRDEQ_INT   (ECAP_ECEINT_CTR_PRD)
 Period Equal Interrupt Enable. More...
 
#define ECAP_CMPEQ_INT   (ECAP_ECEINT_CTR_CMP)
 Compare Equal Interrupt Enable. More...
 

ECAP Global Interrupt Source

#define ECAP_GLOBAL_INT   (ECAP_ECFLG_INT)
 Global Interrupt Source Clear Flag. More...
 

ECAP Capture Event Polarity

#define ECAP_CAPTURE_EVENT_RISING   (0U)
 Capture Event Rising Edge. More...
 
#define ECAP_CAPTURE_EVENT_FALLING   (1U)
 Capture Event Falling Edge. More...
 

ECAP Counter Reset On Capture Event

#define ECAP_CAPTURE_EVENT_RESET_COUNTER_NO_RESET   (0U)
 No counter reset upon Capture Event. More...
 
#define ECAP_CAPTURE_EVENT_RESET_COUNTER_RESET   (1U)
 Counter reset upon Capture Event. More...
 

Macro Definition Documentation

◆ ECAP_CAPTURE_MODE

#define ECAP_CAPTURE_MODE   (0U)

Capture Mode.

◆ ECAP_APWM_MODE

#define ECAP_APWM_MODE   (1U)

Auxiliary PWM Mode.

◆ ECAP_CAPTURE_EVENT_1

#define ECAP_CAPTURE_EVENT_1   ((uint32_t)0x08U)

Time stamp capture on event 1.

◆ ECAP_CAPTURE_EVENT_2

#define ECAP_CAPTURE_EVENT_2   ((uint32_t)0x0cU)

Time stamp capture on event 2.

◆ ECAP_CAPTURE_EVENT_3

#define ECAP_CAPTURE_EVENT_3   ((uint32_t)0x10U)

Time stamp capture on event 3.

◆ ECAP_CAPTURE_EVENT_4

#define ECAP_CAPTURE_EVENT_4   ((uint32_t)0x14U)

Time stamp capture on event 4.

◆ ECAP_CAPTURE_EVENT1_STOP

#define ECAP_CAPTURE_EVENT1_STOP   ((uint32_t)0x00U)

Stop capture after event 1.

◆ ECAP_CAPTURE_EVENT2_STOP

#define ECAP_CAPTURE_EVENT2_STOP   ((uint32_t)0x01U)

Stop capture after event 2.

◆ ECAP_CAPTURE_EVENT3_STOP

#define ECAP_CAPTURE_EVENT3_STOP   ((uint32_t)0x02U)

Stop capture after event 3.

◆ ECAP_CAPTURE_EVENT4_STOP

#define ECAP_CAPTURE_EVENT4_STOP   ((uint32_t)0x03U)

Stop capture after event 4.

◆ ECAP_APWM_ACTIVE_HIGH

#define ECAP_APWM_ACTIVE_HIGH   (0U)

Output Polarity HIGH.

◆ ECAP_APWM_ACTIVE_LOW

#define ECAP_APWM_ACTIVE_LOW   (1U)

Output Polarity LOW.

◆ ECAP_COUNTER_STOP

#define ECAP_COUNTER_STOP   (0U)

Counter Mode Stop.

◆ ECAP_COUNTER_FREE_RUNNING

#define ECAP_COUNTER_FREE_RUNNING   (1U)

Counter Mode Free Running.

◆ ECAP_SYNC_IN_DISABLE

#define ECAP_SYNC_IN_DISABLE   ((uint32_t)0U)

Disable SyncIn option.

◆ ECAP_ENABLE_COUNTER

#define ECAP_ENABLE_COUNTER   ((uint32_t)1U)

Enable Counter to be loaded from the ECAP_CNTPHS register upon SYNCI signal.

◆ ECAP_SYNC_IN

#define ECAP_SYNC_IN   ((uint32_t)0x0U)

Select SyncIn event to be the SyncOut signal.

◆ ECAP_PRD_EQ

#define ECAP_PRD_EQ   ((uint32_t)0x1U)

Select PRD event to be the SyncOut signal.

◆ ECAP_SYNC_OUT_DISABLE

#define ECAP_SYNC_OUT_DISABLE   ((uint32_t)0x2U)

Disable SyncOut Signal.

◆ ECAP_CEVT1_INT

#define ECAP_CEVT1_INT   (ECAP_ECEINT_CEVT1)

Capture Event 1 Interrupt Enable.

◆ ECAP_CEVT2_INT

#define ECAP_CEVT2_INT   (ECAP_ECEINT_CEVT2)

Capture Event 2 Interrupt Enable.

◆ ECAP_CEVT3_INT

#define ECAP_CEVT3_INT   (ECAP_ECEINT_CEVT3)

Capture Event 3 Interrupt Enable.

◆ ECAP_CEVT4_INT

#define ECAP_CEVT4_INT   (ECAP_ECEINT_CEVT4)

Capture Event 4 Interrupt Enable.

◆ ECAP_CNTOVF_INT

#define ECAP_CNTOVF_INT   (ECAP_ECEINT_CTROVF)

Counter Overflow Interrupt Enable.

◆ ECAP_PRDEQ_INT

#define ECAP_PRDEQ_INT   (ECAP_ECEINT_CTR_PRD)

Period Equal Interrupt Enable.

◆ ECAP_CMPEQ_INT

#define ECAP_CMPEQ_INT   (ECAP_ECEINT_CTR_CMP)

Compare Equal Interrupt Enable.

◆ ECAP_GLOBAL_INT

#define ECAP_GLOBAL_INT   (ECAP_ECFLG_INT)

Global Interrupt Source Clear Flag.

◆ ECAP_CAPTURE_EVENT_RISING

#define ECAP_CAPTURE_EVENT_RISING   (0U)

Capture Event Rising Edge.

◆ ECAP_CAPTURE_EVENT_FALLING

#define ECAP_CAPTURE_EVENT_FALLING   (1U)

Capture Event Falling Edge.

◆ ECAP_CAPTURE_EVENT_RESET_COUNTER_NO_RESET

#define ECAP_CAPTURE_EVENT_RESET_COUNTER_NO_RESET   (0U)

No counter reset upon Capture Event.

◆ ECAP_CAPTURE_EVENT_RESET_COUNTER_RESET

#define ECAP_CAPTURE_EVENT_RESET_COUNTER_RESET   (1U)

Counter reset upon Capture Event.

Function Documentation

◆ ECAP_captureLoadingEnable()

void ECAP_captureLoadingEnable ( uint32_t  baseAddr)

This function enables capture loading.

Parameters
baseAddrIt is the Memory address of the ECAP instance used.

◆ ECAP_captureLoadingDisable()

void ECAP_captureLoadingDisable ( uint32_t  baseAddr)

This function disables capture loading.

Parameters
baseAddrIt is the Memory address of the ECAP instance used.

◆ ECAP_prescaleConfig()

void ECAP_prescaleConfig ( uint32_t  baseAddr,
uint32_t  prescale 
)

This function configures prescale value.

Parameters
baseAddrIt is the Memory address of the ECAP instance used.
prescaleIt is the value which is used to prescale the incoming input.

Prescale can take any integer value between 0 to 31

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

Parameters
baseAddrIt is the Memory address of the ECAP instance used.
modeSelectIt is the value which determines whether ecapture module to operate in capture mode or in APWM mode.
modeSelect can take one of the following macros.

◆ ECAP_timeStampRead()

uint32_t ECAP_timeStampRead ( uint32_t  baseAddr,
uint32_t  capEvtFlag 
)

This function returns time-stamp for a given capture event.

Parameters
baseAddrIt is the Memory address of the ECAP instance used.
capEvtFlagIt is the value which determines for which capture event time-stam has to returned.

capEvtFlag can take one of the following macros.

Returns
Returns the time-stamp for given capure event.

◆ ECAP_counterConfig()

void ECAP_counterConfig ( uint32_t  baseAddr,
uint32_t  countVal 
)

This function configures the counter register which is used as Capture Time base.

Parameters
baseAddrIt is the Memory address of the ECAP instance used.
countValIt is counter value to be configured.

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

Parameters
baseAddrIt is the Memory address of the ECAP instance used.
capEvt1polIt determines whether Capture Event1 has to be generated on rising edge or falling edge of pulse.
capEvt2polIt determines whether Capture Event2 has to be generated on rising edge or falling edge of pulse.
capEvt3polIt determines whether Capture Event3 has to be generated on rising edge or falling edge of pulse.
capEvt4polIt determines whether Capture Event4 has to be generated on rising edge or falling edge of pulse.

capEvtpol variables can take one of the following macros.

◆ ECAP_captureEvtCntrRstConfig()

void ECAP_captureEvtCntrRstConfig ( uint32_t  baseAddr,
uint32_t  counterRst1,
uint32_t  counterRst2,
uint32_t  counterRst3,
uint32_t  counterRst4 
)

This function enables reset of the counters upon Capture Events.

Parameters
baseAddrIt is the Memory address of the ECAP instance used.
counterRst1It determines whether counter has to be reset upon Capture Event1.
counterRst2It determines whether counter has to be reset upon Capture Event2.
counterRst3It determines whether counter has to be reset upon Capture Event3.
counterRst4It determines whether counter has to be reset upon Capture Event4.

counterRst variables can take one of the following macros.

◆ ECAP_continousModeConfig()

void ECAP_continousModeConfig ( uint32_t  baseAddr)

This function configures ECAP to Continuous mode.

This API is valid only if ECAP is configured to Capture Mode.It has no significance when ECAP is configured in APWM mode.

Parameters
baseAddrIt is the Memory address of the ECAP instance used.

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

This API is valid only if ECAP is configured to Capture Mode.It has no significance when ECAP is configured in APWM mode.

Parameters
baseAddrIt is the Memory address of the ECAP instance used.
stopValIt is the number of captures allowed to occur before Capture register(1-4) are frozen.
stopVal can take one of the following macros.

◆ ECAP_oneShotReArm()

void ECAP_oneShotReArm ( uint32_t  baseAddr)

This function configures ECAP to One-Short Re-arming.

When this API is invoked following things happen.

  1. Resets Mod4 counter to zero.
  2. Un-freezes the Mod4 counter.
  3. Enables capture register loads.
    Parameters
    baseAddrIt is the Memory address of the ECAP instance used.

◆ ECAP_APWM_polarityConfig()

void ECAP_APWM_polarityConfig ( uint32_t  baseAddr,
uint32_t  flag 
)

This function configures output polarity for APWM output.

Parameters
baseAddrIt is the Memory address of the ECAP instance used.
flagIt is the value which determines the output polarity for APWM output.
flag can take one of the following macros.

◆ ECAP_counterControl()

void ECAP_counterControl ( uint32_t  baseAddr,
uint32_t  flag 
)

This function configures counter to stop or free running based on its input argument flag.

Parameters
baseAddrIt is the Memory address of the ECAP instance used.
flagIt is the value which determine counter to be configured to stop or free running.
flag can take one of the following macros.

◆ ECAP_syncInOutSelect()

void ECAP_syncInOutSelect ( uint32_t  baseAddr,
uint32_t  syncIn,
uint32_t  syncOut 
)

This function configures Sync-In and Sync-Out.

Parameters
baseAddrIt is the Memory address of the ECAP instance used.
syncInIt is the value which determines whether to disable syncIn or to enable counter to be loaded from CNTPHS register upon a SYNCI signal.
syncIn can take one of the following macros.
syncOutIt is the value which select type of syncOut signal (i.e select syncIn event to be the Sync-Out signal, select PRD_eq event to be Sync-Out signal).
syncOut can take one of the following macros.

◆ ECAP_APWM_captureConfig()

void ECAP_APWM_captureConfig ( uint32_t  baseAddr,
uint32_t  compareVal,
uint32_t  periodVal 
)

When ECAP module is configured in APWM mode capture 1 and capture 2 registers are used as period and compare register.This function configures compare and period values to this register.

Parameters
baseAddrIt is the Memory address of the ECAP instance used.
compareValIt is the Compare value to be configured.
periodValIt is the Period value to be configured.

◆ ECAP_APWM_shadowCaptureConfig()

void ECAP_APWM_shadowCaptureConfig ( uint32_t  baseAddr,
uint32_t  compareVal,
uint32_t  periodVal 
)

This function configures the Shadow register.

Parameters
baseAddrIt is the Memory address of the ECAP instance used.
compareValIt is the Compare value to be configured.
periodValIt is the Period value to be configured.

◆ ECAP_counterPhaseValConfig()

void ECAP_counterPhaseValConfig ( uint32_t  baseAddr,
uint32_t  cntPhaseVal 
)

This function configures the counter phase value.

Parameters
baseAddrIt is the Memory address of the ECAP instance used.
cntPhaseValIt is the counter phase value to be programmed for phase lag/lead.

◆ ECAP_globalIntrClear()

void ECAP_globalIntrClear ( uint32_t  baseAddr)

This function clears global interrupt and enables the generation of interrupts if any of the event interrupt are enabled and corresponding event interrupt flag is set.

Parameters
baseAddrIt is the Memory address of the ECAP instance used.

◆ ECAP_intrEnable()

void ECAP_intrEnable ( uint32_t  baseAddr,
uint32_t  flag 
)

This function enables the specified interrupts.

Parameters
baseAddrIt is the Memory address of the ECAP instance used.
flagIt is the value which specifies the interrupts to be enabled.
flag can take one of the following macros.

◆ ECAP_intrDisable()

void ECAP_intrDisable ( uint32_t  baseAddr,
uint32_t  flag 
)

This function disables the specified interrupts.

Parameters
baseAddrIt is the Memory address of the ECAP instance used.
flagIt is the value which specifies the interrupts to be disabled.
flag can take one of the following macros.

◆ ECAP_getIntrStatus()

uint32_t ECAP_getIntrStatus ( uint32_t  baseAddr,
uint32_t  flag 
)

This function returns the status specified interrupts.

Parameters
baseAddrIt is the Memory address of the ECAP instance used.
flagIt is the value which specifies the status of interrupts to be returned.
flag can take one of the following macros.
Returns
Status of the specified interrupts.

◆ ECAP_intrStatusClear()

void ECAP_intrStatusClear ( uint32_t  baseAddr,
uint32_t  flag 
)

This function clears of the status specified interrupts.

Parameters
baseAddrIt is the Memory address of the ECAP instance used.
flagIt is the value which specifies the status of interrupts to be cleared.
flag can take one of the following macros.

◆ ECAP_peripheralIdGet()

uint32_t ECAP_peripheralIdGet ( uint32_t  baseAddr)

This function returns the peripheral ID.

Parameters
baseAddrIt is the Memory address of the ECAP instance used.
Returns
Peripheral ID.