AM64x MCU+ SDK  08.03.00
EQEP

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

Features Supported

  • Configuration of position counter and control unit for position and direction measurement
  • Configuration of unit time base for speed and frequency measurement
  • Configuration of quadrature edge capture unit for low-speed measurement
  • Configuration of watchdog timer for detecting stalls

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.

  • EQEP 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/eqep.h>

EQEP Interrupt Registration

int32_t status = SystemP_SUCCESS;
HwiP_Params hwiPrms;
/* Register & enable interrupt */
HwiP_Params_init(&hwiPrms);
hwiPrms.intNum = CONFIG_EQEP0_INTR;
hwiPrms.callback = &App_eqepIntrISR;
hwiPrms.isPulse = CONFIG_EQEP0_INTR_IS_PULSE;
status = HwiP_construct(&gEqepHwiObject, &hwiPrms);

EQEP Quadrature Mode Position Measurement Configuration

/* Configure the decoder for quadrature mode, counting rising edge
(that is, 1x resolution) */
/* Configure the position counter to reset on an index event */
CSL_EQEP_QPOSCNT_QPOSCNT_MAX);
/* Configure the position counter to be latched on rising edge index */
/* Enable EQEP Module and Interrupt */
EQEP_enableModule(gEqepBaseAddr);

EQEP Quadrature Mode Frequency Measurement Configuration

/* Configure the decoder for up-count mode, counting both rising and
falling edges (that is, 2x resolution) */
/* Configure the position counter to reset on an unit timeout event */
CSL_EQEP_QPOSCNT_QPOSCNT_MAX);
/* Enable the unit timer, setting the frequency to EQEP_UNIT_TIMEOUT_FREQ */
EQEP_enableUnitTimer(gEqepBaseAddr, (CONFIG_EQEP0_FCLK / (EQEP_UNIT_TIMEOUT_FREQ)));
/* Configure the position counter to be latched on a unit time out */
/* Enable the EQEP module */
EQEP_enableModule(gEqepBaseAddr);
/* Configure and enable the edge-capture unit. The capture clock divider is
SYSCLKOUT/128. The unit-position event divider is QCLK/8. */
EQEP_enableCapture(gEqepBaseAddr);
/* Enable unit timeout interrupt. */

EQEP Interrupt Service Routine

intStatus = EQEP_getInterruptStatus(gEqepBaseAddr);
intEnabled = EQEP_getEnabledInterrupt(gEqepBaseAddr);
if (((intStatus & EQEP_INT_INDEX_EVNT_LATCH) != 0) &&
((intEnabled & EQEP_INT_INDEX_EVNT_LATCH) != 0))
{
/* Get the position latch count */
if (gEqepIsrCnt < EQEP_EVENT_CNT)
{
gEqepPosCnt[gEqepIsrCnt] = EQEP_getIndexPositionLatch(gEqepBaseAddr);
}
if (gEqepIsrCnt == (EQEP_EVENT_CNT - 1))
{
EQEP_disableInterrupt(gEqepBaseAddr, EQEP_INT_ALL);
SemaphoreP_post(&gEqepSyncSem);
}
gEqepIsrCnt++;
}
if (((intStatus & EQEP_INT_UNIT_TIME_OUT) != 0) &&
((intEnabled & EQEP_INT_UNIT_TIME_OUT) != 0))
{
/* Get the position latch count */
if (gEqepIsrCnt < EQEP_EVENT_CNT)
{
gEqepPosCnt[gEqepIsrCnt] = EQEP_getPositionLatch(gEqepBaseAddr);
}
if (gEqepIsrCnt == (EQEP_EVENT_CNT - 1))
{
EQEP_disableInterrupt(gEqepBaseAddr, EQEP_INT_ALL);
SemaphoreP_post(&gEqepSyncSem);
}
gEqepIsrCnt++;
}
/* Clear EQEP Interrupt. */
EQEP_clearInterruptStatus(gEqepBaseAddr, EQEP_INT_ALL);

EQEP Interrupt De-Registration

HwiP_destruct(&gEqepHwiObject);

API

APIs for EQEP

EQEP_setDecoderConfig
void EQEP_setDecoderConfig(uint32_t baseAddr, uint16_t config)
Configures eQEP module's quadrature decoder unit.
HwiP_destruct
void HwiP_destruct(HwiP_Object *obj)
Cleanup, delete, destruct a Hwi object.
eqep.h
HwiP_Params
Parameters passed during HwiP_construct.
Definition: HwiP.h:72
EQEP_enableUnitTimer
void EQEP_enableUnitTimer(uint32_t baseAddr, uint32_t period)
Enables the eQEP module unit timer.
EQEP_LATCH_RISING_INDEX
#define EQEP_LATCH_RISING_INDEX
Index position counter latch event.
Definition: eqep/v0/eqep.h:193
EQEP_CONFIG_2X_RESOLUTION
#define EQEP_CONFIG_2X_RESOLUTION
Resolution Count rising and falling edge.
Definition: eqep/v0/eqep.h:83
EQEP_POSITION_RESET_UNIT_TIME_OUT
#define EQEP_POSITION_RESET_UNIT_TIME_OUT
Reset position on a unit time event.
Definition: eqep/v0/eqep.h:249
EQEP_CONFIG_1X_RESOLUTION
#define EQEP_CONFIG_1X_RESOLUTION
Resolution Count rising edge only.
Definition: eqep/v0/eqep.h:85
EQEP_CONFIG_NO_SWAP
#define EQEP_CONFIG_NO_SWAP
Do not swap QEPA and QEPB.
Definition: eqep/v0/eqep.h:87
HwiP_construct
int32_t HwiP_construct(HwiP_Object *obj, HwiP_Params *params)
Create a Hwi object.
EQEP_CONFIG_QUADRATURE
#define EQEP_CONFIG_QUADRATURE
Values that can be passed to EQEP_setDecoderConfig() as the config parameter.
Definition: eqep/v0/eqep.h:75
HwiP_Params_init
void HwiP_Params_init(HwiP_Params *params)
Set default values to HwiP_Params.
EQEP_UNIT_POS_EVNT_DIV_8
#define EQEP_UNIT_POS_EVNT_DIV_8
UPEVNT = QCLK/8.
Definition: eqep/v0/eqep.h:299
EQEP_enableModule
void EQEP_enableModule(uint32_t baseAddr)
Enables the eQEP module.
EQEP_disableInterrupt
void EQEP_disableInterrupt(uint32_t baseAddr, uint16_t intFlags)
Disables individual eQEP module interrupt sources.
EQEP_clearInterruptStatus
void EQEP_clearInterruptStatus(uint32_t baseAddr, uint16_t intFlags)
Clears eQEP module interrupt sources.
EQEP_getIndexPositionLatch
uint32_t EQEP_getIndexPositionLatch(uint32_t baseAddr)
Gets the encoder position that was latched on an index event.
EQEP_setCaptureConfig
void EQEP_setCaptureConfig(uint32_t baseAddr, eqepCapClkPrescale_t capPrescale, eqeqUpEvntPrescale_t evntPrescale)
Configures eQEP module edge-capture unit.
SystemP_SUCCESS
#define SystemP_SUCCESS
Return status when the API execution was successful.
Definition: SystemP.h:56
EQEP_getEnabledInterrupt
uint16_t EQEP_getEnabledInterrupt(uint32_t baseAddr)
Get Enabled interrupts of eQEP module.
EQEP_enableCapture
void EQEP_enableCapture(uint32_t baseAddr)
Enables the eQEP module edge-capture unit.
EQEP_getInterruptStatus
uint16_t EQEP_getInterruptStatus(uint32_t baseAddr)
Gets the current interrupt status.
HwiP_Params::isPulse
uint8_t isPulse
Definition: HwiP.h:80
EQEP_POSITION_RESET_IDX
#define EQEP_POSITION_RESET_IDX
Reset position on index pulse.
Definition: eqep/v0/eqep.h:243
EQEP_INT_UNIT_TIME_OUT
#define EQEP_INT_UNIT_TIME_OUT
Unit time-out.
Definition: eqep/v0/eqep.h:146
EQEP_enableInterrupt
void EQEP_enableInterrupt(uint32_t baseAddr, uint16_t intFlags)
Enables individual eQEP module interrupt sources.
EQEP_getPositionLatch
uint32_t EQEP_getPositionLatch(uint32_t baseAddr)
Gets the encoder position that was latched on a unit time-out event.
HwiP_Params::callback
HwiP_FxnCallback callback
Definition: HwiP.h:75
EQEP_INT_INDEX_EVNT_LATCH
#define EQEP_INT_INDEX_EVNT_LATCH
Index event latch.
Definition: eqep/v0/eqep.h:144
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
EQEP_setLatchMode
void EQEP_setLatchMode(uint32_t baseAddr, uint32_t latchMode)
Configures the quadrature modes in which the position count can be latched.
EQEP_LATCH_UNIT_TIME_OUT
#define EQEP_LATCH_UNIT_TIME_OUT
On position counter read.
Definition: eqep/v0/eqep.h:186
HwiP_Params::intNum
uint32_t intNum
Definition: HwiP.h:74
EQEP_setPositionCounterConfig
void EQEP_setPositionCounterConfig(uint32_t baseAddr, eqepPositionResetMode_t mode, uint32_t maxPosition)
Configures eQEP module position counter unit.
EQEP_CAPTURE_CLK_DIV_128
#define EQEP_CAPTURE_CLK_DIV_128
CAPCLK = SYSCLKOUT/128.
Definition: eqep/v0/eqep.h:278
EQEP_CONFIG_UP_COUNT
#define EQEP_CONFIG_UP_COUNT
Up-count mode, QDIR = 1.
Definition: eqep/v0/eqep.h:79