2.76 Quadrature Decoder (PDEC)

The quadrature decoder (QDEC) mode is used to measure the position and speed of the motor. This provides below features:

  • Angular and revolution counts

  • Synchronous and asynchronous velocity measurements

  • Direction change detection

  • Interrupts/output events on:

    • Counter overflow/underflow

    • Velocity

    • Direction change

Using The Library

Quadrature encoder signals Phase A, Phase B and an optional index signal are connected to the PDEC peripheral. The PDEC peripheral processes these signals with an internal counter to get the angular position and revolution count.

For velocity measurement, velocity event output is connected to the TC module using the Event System.

Library Interface

Quadrature Decoder peripheral library provides the following interfaces:

Functions

NameDescription
PDECx_QDECInitializeInitializes given instance of PDEC peripheral in quadrature mode
PDECx_QDECStartStarts the given PDEC counter in quadrature mode
PDECx_QDECStopStops the given PDEC counter in quadrature mode
PDECx_QDECPositionGetReads the angular position from the quadrature encoder
PDECx_QDECRevolutionsGetReads the number of revolutions
PDECx_QDECAngleGetReads the angle
PDECx_QDECCallbackRegisterRegisters the function to be called from interrupt
PDECx_QDECStatusGetIdentifies status of the quadrature interrupts
PDECx_HALLInitializeInitializes given instance of PDEC peripheral in hall mode
PDECx_HALLStartStarts the given PDEC counter in hall mode
PDECx_HALLStopStops the given PDEC counter in hall mode
PDECx_HALLPatternGetReads the hall pattern
PDECx_HALLPatternSetWrites the hall pattern
PDECx_HALLTimeWindowSetWrites the low and high window threshold for hall mode
PDECx_HALLCallbackRegisterRegisters the function to be called from interrupt
PDECx_HALLStatusGetIdentifies status of the hall interrupts
PDECx_COUNTERInitializeInitializes given instance of PDEC peripheral in counter mode
PDECx_COUNTERStartStarts the given PDEC counter in counter mode
PDECx_COUNTERStopStops the given PDEC counter in counter mode
PDECx_COUNTERCompare0SetConfigures Compare 0 register value
PDECx_COUNTERCompare1SetConfigures Compare 0 register value
PDECx_COUNTERCompare0GetReads Compare 0 register value
PDECx_COUNTERCompare1GetReads Compare 1 register value
PDECx_COUNTERCallbackRegisterRegisters the function to be called from interrupt
PDECx_COUNTERStatusGetIdentifies status of the counter mode interrupts

Data types and constants

NameTypeDescription
PDEC_QDEC_STATUSEnumIdentifies Quadrature mode interrupt source mask
PDEC_HALL_STATUSEnumIdentifies Hall mode interrupt source mask
PDEC_COUNTER_STATUSEnumIdentifies counter mode interrupt source mask
PDEC_QDEC_CALLBACKTypedefDefines the function pointer data type and function signature for the pdec QDEC callback function
PDEC_HALL_CALLBACKTypedefDefines the function pointer data type and function signature for the pdec hall callback function
PDEC_COUNTER_CALLBACKTypedefDefines the function pointer data type and function signature for the pdec counter callback function
PDEC_QDEC_CALLBACK_OBJStructCallback structure
PDEC_HALL_CALLBACK_OBJStructCallback structure
PDEC_COUNTER_CALLBACK_OBJStructCallback structure
Note: Not all APIs maybe implemented. See the specific device family section for available APIs.