MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
QDC: Quadrature Decoder Driver

Read Guidance

This document consists of sections titled with Driver Overview, Data Structures, Enumerations, Functions, etc., each with an overview list and detailed documentation. It is recommended to read the Driver Overview first for it includes a comprehensive description of the peripheral, driver and driver changes. Other sections give detailed information for APIs, enums, macros, etc., for your further reference.

Driver Overview

 QDC Peripheral and Driver Overview
 Content including 1) peripheral features, work logic and work method; 2) driver design logic and use method.
 
 The Driver Change Log
 The current QDC driver version is 2.0.0.
 

Data Structures

struct  qdc_config_t
 Define user configuration structure for QDC module. More...
 

Enumerations

enum  _qdc_status_flags {
  kQDC_HomeTransitionFlag = QDC_CTRL_HIRQ_MASK,
  kQDC_IndexPulseFlag = QDC_CTRL_XIRQ_MASK,
  kQDC_WatchdogTimeoutFlag = QDC_CTRL_DIRQ_MASK,
  kQDC_PositionCompareFlag = QDC_CTRL_CMPIRQ_MASK,
  kQDC_SimultPhaseChangeFlag = QDC_CTRL2_SABIRQ_MASK,
  kQDC_PositionRollOverFlag = QDC_CTRL2_ROIRQ_MASK,
  kQDC_PositionRollUnderFlag = QDC_CTRL2_RUIRQ_MASK,
  kQDC_PositionCompare1Flag = QDC_CTRL3_CMP1IRQ_MASK
}
 QDC status flags, these flags indicate the counter's events. More...
 
enum  _qdc_signal_status {
  kQDC_SignalStatusRawHome = QDC_IMR_HOME_MASK,
  kQDC_SignalStatusRawIndex = QDC_IMR_INDEX_MASK,
  kQDC_SignalStatusRawPhaseB = QDC_IMR_PHB_MASK,
  kQDC_SignalStatusRawPhaseA = QDC_IMR_PHA_MASK,
  kQDC_SignalStatusFilteredHome = QDC_IMR_FHOM_MASK,
  kQDC_SignalStatusFilteredIndex = QDC_IMR_FIND_MASK,
  kQDC_SignalStatusFilteredPhaseB = QDC_IMR_FPHB_MASK,
  kQDC_SignalStatusFilteredPhaseA = QDC_IMR_FPHA_MASK
}
 Signal status, these flags indicate the raw and filtered input signal status. More...
 
enum  _qdc_interrupt_enable {
  kQDC_HomeTransitionInterruptEnable = QDC_CTRL_HIE_MASK,
  kQDC_IndexPulseInterruptEnable = QDC_CTRL_XIE_MASK,
  kQDC_WatchdogTimeoutInterruptEnable = QDC_CTRL_DIE_MASK,
  kQDC_PositionCompareInerruptEnable = QDC_CTRL_CMPIE_MASK,
  kQDC_SimultPhaseChangeInterruptEnable = QDC_CTRL2_SABIE_MASK,
  kQDC_PositionRollOverInterruptEnable = QDC_CTRL2_ROIE_MASK,
  kQDC_PositionRollUnderInterruptEnable = QDC_CTRL2_RUIE_MASK,
  kQDC_PositionCompare1InerruptEnable = QDC_CTRL3_CMP1IE_MASK
}
 Interrupt enable/disable mask. More...
 
enum  qdc_home_init_pos_counter_mode_t {
  kQDC_HomeInitPosCounterDisabled = 0U,
  kQDC_HomeInitPosCounterOnRisingEdge = QDC_CTRL_HIP_MASK,
  kQDC_HomeInitPosCounterOnFallingEdge = QDC_CTRL_HIP_MASK | QDC_CTRL_HNE_MASK
}
 Define HOME signal's trigger mode. More...
 
enum  qdc_index_init_pos_counter_mode_t {
  kQDC_IndexInitPosCounterDisabled = 0U,
  kQDC_IndexInitPosCounterOnRisingEdge = QDC_CTRL_XIP_MASK,
  kQDC_IndexInitPosCounterOnFallingEdge = QDC_CTRL_XIP_MASK | QDC_CTRL_XNE_MASK
}
 Define INDEX signal's trigger mode. More...
 
enum  qdc_decoder_work_mode_t {
  kQDC_DecoderQuadratureMode = 0U,
  kQDC_DecoderSignalPhaseCountMode
}
 Define type for decoder work mode. More...
 
enum  qdc_output_pulse_mode_t {
  kQDC_OutputPulseOnCounterEqualCompare = 0U,
  kQDC_OutputPulseOnReadingPositionCounter
}
 Define type for the condition of POSMATCH pulses. More...
 
enum  qdc_revolution_count_condition_t {
  kQDC_RevolutionCountOnIndexPulse = 0U,
  kQDC_RevolutionCountOnRollOverModulus
}
 Define type for determining how the revolution counter (REV) is incremented/decremented. More...
 
enum  qdc_filter_sample_count_t {
  kQDC_Filter3Samples = 0U,
  kQDC_Filter4Samples = 1U,
  kQDC_Filter5Samples = 2U,
  kQDC_Filter6Samples = 3U,
  kQDC_Filter7Samples = 4U,
  kQDC_Filter8Samples = 5U,
  kQDC_Filter9Samples = 6U,
  kQDC_Filter10Samples = 7U
}
 Input Filter Sample Count. More...
 
enum  qdc_count_direction_flag_t {
  kQDC_CountDirectionDown = 0U,
  kQDC_CountDirectionUp
}
 Count direction. More...
 
enum  qdc_prescaler_t {
  kQDC_Prescaler1 = 0U,
  kQDC_Prescaler2 = 1U,
  kQDC_Prescaler4 = 2U,
  kQDC_Prescaler8 = 3U,
  kQDC_Prescaler16 = 4U,
  kQDC_Prescaler32 = 5U,
  kQDC_Prescaler64 = 6U,
  kQDC_Prescaler128 = 7U,
  kQDC_Prescaler256 = 8U,
  kQDC_Prescaler512 = 9U,
  kQDC_Prescaler1024 = 10U,
  kQDC_Prescaler2048 = 11U,
  kQDC_Prescaler4096 = 12U,
  kQDC_Prescaler8192 = 13U,
  kQDC_Prescaler16384 = 14U,
  kQDC_Prescaler32768 = 15U
}
 Prescaler used by Last Edge Time (LASTEDGE) and Position Difference Period Counter (POSDPER). More...
 

Driver version

#define FSL_QDC_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))
 

Initialization and deinitialization Interfaces

void QDC_Init (QDC_Type *base, const qdc_config_t *psConfig)
 Initializes the QDC module. More...
 
void QDC_GetDefaultConfig (qdc_config_t *psConfig)
 Gets an available pre-defined configuration. More...
 
void QDC_Deinit (QDC_Type *base)
 De-initializes the QDC module. More...
 

Watchdog

static void QDC_EnableWatchdog (QDC_Type *base, bool bEnable)
 Enable watchdog for QDC module. More...
 
static void QDC_SetWatchdogTimeout (QDC_Type *base, uint16_t u16Timeout)
 Set watchdog timeout value. More...
 

Status

static uint16_t QDC_GetStatusFlags (QDC_Type *base)
 Get the status flags. More...
 
static void QDC_ClearStatusFlags (QDC_Type *base, uint16_t u16Flags)
 Clear the status flags. More...
 
static uint16_t QDC_GetSignalStatusFlags (QDC_Type *base)
 Get the signals' real-time status. More...
 
static qdc_count_direction_flag_t QDC_GetLastCountDirection (QDC_Type *base)
 Get the direction of the last count. More...
 

Interrupts

static void QDC_EnableInterrupts (QDC_Type *base, uint16_t u16Interrupts)
 Enable the interrupts. More...
 
static void QDC_DisableInterrupts (QDC_Type *base, uint16_t u16Interrupts)
 Disable the interrupts. More...
 

Counter Operation

static void QDC_DoSoftwareLoadInitialPositionValue (QDC_Type *base)
 Load the initial position value to position counter. More...
 
static void QDC_SetInitialPositionValue (QDC_Type *base, uint32_t u32PositionInitValue)
 Set initial position value for QDC module. More...
 
static void QDC_SetPositionCounterValue (QDC_Type *base, uint32_t u32PositionCounterValue)
 Set position counter value. More...
 
static void QDC_SetPositionModulusValue (QDC_Type *base, uint32_t u32PositionModulusValue)
 Set position counter modulus value. More...
 
static void QDC_SetPositionCompareValue (QDC_Type *base, uint32_t u32PositionCompValue)
 Set position counter compare value. More...
 
static void QDC_SetPositionCompare1Value (QDC_Type *base, uint32_t u32PositionComp1Value)
 Set position counter compare 1 value. More...
 
static uint32_t QDC_GetPosition (QDC_Type *base)
 Get the current position counter's value. More...
 
static uint32_t QDC_GetHoldPosition (QDC_Type *base)
 Get the hold position counter's value. More...
 
static uint16_t QDC_GetPositionDifference (QDC_Type *base)
 Get the position difference counter's value. More...
 
static uint16_t QDC_GetHoldPositionDifference (QDC_Type *base)
 Get the hold position difference counter's value. More...
 
static uint16_t QDC_GetRevolution (QDC_Type *base)
 Get the revolution counter's value. More...
 
static uint16_t QDC_GetHoldRevolution (QDC_Type *base)
 Get the hold revolution counter's value. More...
 
static uint16_t QDC_GetLastEdgeTime (QDC_Type *base)
 Get the last edge time. More...
 
static uint16_t QDC_GetHoldLastEdgeTime (QDC_Type *base)
 Get the hold last edge time. More...
 
static uint16_t QDC_GetPositionDifferencePeriod (QDC_Type *base)
 Get the Position Difference Period counter value. More...
 
static uint16_t QDC_GetBufferedPositionDifferencePeriod (QDC_Type *base)
 Get buffered Position Difference Period counter value. More...
 
static uint16_t QDC_GetHoldPositionDifferencePeriod (QDC_Type *base)
 Get Hold Position Difference Period counter value. More...
 

Data Structure Documentation

struct qdc_config_t

Data Fields

bool bEnableReverseDirection
 Enable reverse direction counting. More...
 
qdc_decoder_work_mode_t eDecoderWorkMode
 Use standard quadrature decoder mode or signal phase count mode. More...
 
qdc_home_init_pos_counter_mode_t eHomeInitPosCounterMode
 Select how HOME signal used to initialize position counters. More...
 
qdc_index_init_pos_counter_mode_t eIndexInitPosCounterMode
 Select how INDEX signal used to initialize position counters. More...
 
bool bEnableTriggerInitPositionCounter
 Initialize position counter with initial register(UINIT, LINIT) value on TRIGGER's rising edge. More...
 
bool bEnableTriggerClearPositionRegisters
 
Clear position counter(POS), revolution counter(REV), position

difference counter (POSD) on TRIGGER's rising edge. More...

 
bool bEnableTriggerHoldPositionRegisters
 
Load position counter(POS), revolution counter(REV), position

difference counter (POSD) values to hold registers on TRIGGER's rising edge. More...

 
bool bEnableWatchdog
 Enable the watchdog to detect if the target is moving or not. More...
 
uint16_t u16WatchdogTimeoutValue
 Watchdog timeout count value. More...
 
qdc_filter_sample_count_t eFilterSampleCount
 Input Filter Sample Count. More...
 
uint8_t u8FilterSamplePeriod
 Input Filter Sample Period. More...
 
qdc_output_pulse_mode_t eOutputPulseMode
 The condition of POSMATCH pulses. More...
 
uint32_t u32PositionCompareValue
 Position compare value. More...
 
uint32_t u32PositionCompare1Value
 Position compare 1 value. More...
 
qdc_revolution_count_condition_t eRevolutionCountCondition
 Revolution Counter Modulus Enable. More...
 
bool bEnableModuloCountMode
 Enable Modulo Counting. More...
 
uint32_t u32PositionModulusValue
 Position modulus value. More...
 
uint32_t u32PositionInitialValue
 Position initial value. More...
 
uint32_t u32PositionCounterValue
 Position counter value. More...
 
bool bEnablePeriodMeasurement
 Enable period measurement. More...
 
qdc_prescaler_t ePrescaler
 Prescaler. More...
 
uint16_t u16EnabledInterruptsMask
 Mask of interrupts to be enabled, should be OR'ed value of _qdc_interrupt_enable. More...
 

Field Documentation

bool qdc_config_t::bEnableReverseDirection
qdc_decoder_work_mode_t qdc_config_t::eDecoderWorkMode
qdc_home_init_pos_counter_mode_t qdc_config_t::eHomeInitPosCounterMode
qdc_index_init_pos_counter_mode_t qdc_config_t::eIndexInitPosCounterMode
bool qdc_config_t::bEnableTriggerInitPositionCounter
bool qdc_config_t::bEnableTriggerClearPositionRegisters
bool qdc_config_t::bEnableTriggerHoldPositionRegisters
bool qdc_config_t::bEnableWatchdog
uint16_t qdc_config_t::u16WatchdogTimeoutValue

It stores the timeout count for the quadrature decoder module watchdog timer.

qdc_filter_sample_count_t qdc_config_t::eFilterSampleCount

This value should be chosen to reduce the probability of noisy samples causing an incorrect transition to be recognized. The value represent the number of consecutive samples that must agree prior to the input filter accepting an input transition.

uint8_t qdc_config_t::u8FilterSamplePeriod

This value should be set such that the sampling period is larger than the period of the expected noise. This value represents the sampling period (in IPBus clock cycles) of the decoder input signals. The available range is 0 - 255.

qdc_output_pulse_mode_t qdc_config_t::eOutputPulseMode
uint32_t qdc_config_t::u32PositionCompareValue

The available value is a 32-bit number.

uint32_t qdc_config_t::u32PositionCompare1Value

The available value is a 32-bit number.

qdc_revolution_count_condition_t qdc_config_t::eRevolutionCountCondition
bool qdc_config_t::bEnableModuloCountMode
uint32_t qdc_config_t::u32PositionModulusValue

Only used when bEnableModuloCountMode is true. The available value is a 32-bit number.

uint32_t qdc_config_t::u32PositionInitialValue

The available value is a 32-bit number.

uint32_t qdc_config_t::u32PositionCounterValue

When Modulo mode enabled, the u32PositionCounterValue should be in the range of u32PositionInitialValue and u32PositionModulusValue.

bool qdc_config_t::bEnablePeriodMeasurement

When enabled, the position difference hold register (POSDH) is only updated when position difference register (POSD) is read.

qdc_prescaler_t qdc_config_t::ePrescaler
uint16_t qdc_config_t::u16EnabledInterruptsMask

Enumeration Type Documentation

Enumerator
kQDC_HomeTransitionFlag 

HOME signal transition occured.

kQDC_IndexPulseFlag 

INDEX pulse occured.

kQDC_WatchdogTimeoutFlag 

Watchdog timeout occured.

kQDC_PositionCompareFlag 

Position counter match the COMP value.

kQDC_SimultPhaseChangeFlag 

Simultaneous change of PHASEA and PHASEB occured.

kQDC_PositionRollOverFlag 

Position counter rolls over from 0xFFFFFFFF to 0, or from MOD value to INIT value.

kQDC_PositionRollUnderFlag 

Position register roll under from 0 to 0xFFFFFFFF, or from INIT value to MOD value.

kQDC_PositionCompare1Flag 

Position counter match the COMP1 value.

Enumerator
kQDC_SignalStatusRawHome 

Raw HOME input.

kQDC_SignalStatusRawIndex 

Raw INDEX input.

kQDC_SignalStatusRawPhaseB 

Raw PHASEB input.

kQDC_SignalStatusRawPhaseA 

Raw PHASEA input.

kQDC_SignalStatusFilteredHome 

The filtered HOME input.

kQDC_SignalStatusFilteredIndex 

The filtered INDEX input.

kQDC_SignalStatusFilteredPhaseB 

The filtered PHASEB input.

kQDC_SignalStatusFilteredPhaseA 

The filtered PHASEA input.

Enumerator
kQDC_HomeTransitionInterruptEnable 

HOME signal transition interrupt enable.

kQDC_IndexPulseInterruptEnable 

INDEX pulse interrupt enable.

kQDC_WatchdogTimeoutInterruptEnable 

Watchdog timeout interrupt enable.

kQDC_PositionCompareInerruptEnable 

Position compare interrupt enable.

kQDC_SimultPhaseChangeInterruptEnable 

Simultaneous PHASEA and PHASEB change interrupt enable.

kQDC_PositionRollOverInterruptEnable 

Roll-over interrupt enable.

kQDC_PositionRollUnderInterruptEnable 

Roll-under interrupt enable.

kQDC_PositionCompare1InerruptEnable 

Position compare 1 interrupt enable.

Enumerator
kQDC_HomeInitPosCounterDisabled 

Don't use HOME signal to initialize the position counter.

kQDC_HomeInitPosCounterOnRisingEdge 

Use positive going edge to trigger initialization of position counters.

kQDC_HomeInitPosCounterOnFallingEdge 

Use negative going edge to trigger initialization of position counters.

Enumerator
kQDC_IndexInitPosCounterDisabled 

INDEX pulse does not initialize the position counter.

kQDC_IndexInitPosCounterOnRisingEdge 

Use INDEX pulse rising edge to initialize position counter.

kQDC_IndexInitPosCounterOnFallingEdge 

Use INDEX pulse falling edge to initialize position counter.

In normal work mode uses the standard quadrature decoder with PHASEA and PHASEB. In signal phase count mode, a positive transition of the PHASEA input generates a count signal while the PHASEB input and the reverse direction control the counter direction. If the reverse direction is not enabled, PHASEB = 0 means counting up and PHASEB = 1 means counting down. If the reverse direction is enabled, PHASEB = 0 means counting down and PHASEB = 1 means counting up.

Enumerator
kQDC_DecoderQuadratureMode 

Use standard quadrature decoder with PHASEA and PHASEB.

kQDC_DecoderSignalPhaseCountMode 

PHASEA input generates a count signal while PHASEB input control the direction.

Enumerator
kQDC_OutputPulseOnCounterEqualCompare 

POSMATCH pulses when a match occurs between the position counters (POS) and the compare value (COMP, COMP1).

kQDC_OutputPulseOnReadingPositionCounter 

POSMATCH pulses when reading position counter(POS), revolution counter(REV), position difference counter(POSD).

Enumerator
kQDC_RevolutionCountOnIndexPulse 

Use INDEX pulse to increment/decrement revolution counter.

kQDC_RevolutionCountOnRollOverModulus 

Use modulus counting roll-over/under to increment/decrement revolution counter.

The Input Filter Sample Count represents the number of consecutive samples that must agree, before the input filter accepts an input transition

Enumerator
kQDC_Filter3Samples 

3 samples.

kQDC_Filter4Samples 

4 samples.

kQDC_Filter5Samples 

5 samples.

kQDC_Filter6Samples 

6 samples.

kQDC_Filter7Samples 

7 samples.

kQDC_Filter8Samples 

8 samples.

kQDC_Filter9Samples 

9 samples.

kQDC_Filter10Samples 

10 samples.

Enumerator
kQDC_CountDirectionDown 

Last count was in down direction.

kQDC_CountDirectionUp 

Last count was in up direction.

Enumerator
kQDC_Prescaler1 

Prescaler value 1.

kQDC_Prescaler2 

Prescaler value 2.

kQDC_Prescaler4 

Prescaler value 4.

kQDC_Prescaler8 

Prescaler value 8.

kQDC_Prescaler16 

Prescaler value 16.

kQDC_Prescaler32 

Prescaler value 32.

kQDC_Prescaler64 

Prescaler value 64.

kQDC_Prescaler128 

Prescaler value 128.

kQDC_Prescaler256 

Prescaler value 256.

kQDC_Prescaler512 

Prescaler value 512.

kQDC_Prescaler1024 

Prescaler value 1024.

kQDC_Prescaler2048 

Prescaler value 2048.

kQDC_Prescaler4096 

Prescaler value 4096.

kQDC_Prescaler8192 

Prescaler value 8192.

kQDC_Prescaler16384 

Prescaler value 16384.

kQDC_Prescaler32768 

Prescaler value 32768.

Function Documentation

void QDC_Init ( QDC_Type *  base,
const qdc_config_t psConfig 
)

This function initializes the QDC by:

  1. Enable the IP bus clock (optional).
  2. Configure module based on the configuration structure.
Parameters
baseQDC peripheral base address.
psConfigPointer to configuration structure.
void QDC_GetDefaultConfig ( qdc_config_t psConfig)

The default value are:

psConfig->bEnableReverseDirection = false;
psConfig->eDecoderWorkMode = kQDC_DecoderQuadratureMode;
psConfig->eHomeInitPosCounterMode = kQDC_HomeInitPosCounterDisabled;
psConfig->eIndexInitPosCounterMode = kQDC_IndexInitPosCounterDisabled;
psConfig->bEnableTriggerInitPositionCounter = false;
psConfig->bEnableTriggerClearPositionRegisters = false;
psConfig->bEnableTriggerHoldPositionRegisters = false;
psConfig->bEnableWatchdog = false;
psConfig->u16WatchdogTimeoutValue = 0xFFFFU;
psConfig->eFilterSampleCount = kQDC_Filter3Samples;
psConfig->u8FilterSamplePeriod = 0U;
psConfig->eOutputPulseMode = kQDC_OutputPulseOnCounterEqualCompare;
psConfig->u32PositionCompareValue = 0xFFFFFFFFU;
psConfig->u32PositionCompare1Value = 0xFFFFFFFFU;
psConfig->eRevolutionCountCondition = kQDC_RevolutionCountOnIndexPulse;
psConfig->bEnableModuloCountMode = false;
psConfig->u32PositionModulusValue = 0U;
psConfig->u32PositionInitialValue = 0U;
psConfig->u32PositionCounterValue = 0U;
psConfig->bEnablePeriodMeasurement = false;
psConfig->ePrescaler = kQDC_Prescaler1;
psConfig->u16EnabledInterruptsMask = 0U;
Parameters
psConfigPointer to configuration structure.
void QDC_Deinit ( QDC_Type *  base)

This function deinitializes the QDC by:

  1. Disables the IP bus clock (optional).
Parameters
baseQDC peripheral base address.
static void QDC_EnableWatchdog ( QDC_Type *  base,
bool  bEnable 
)
inlinestatic
Parameters
baseQDC peripheral base address
bEnableEnables or disables the watchdog
static void QDC_SetWatchdogTimeout ( QDC_Type *  base,
uint16_t  u16Timeout 
)
inlinestatic
Parameters
baseQDC peripheral base address
u16TimeoutNumber of clock cycles, plus one clock cycle that the watchdog timer counts before timing out
static uint16_t QDC_GetStatusFlags ( QDC_Type *  base)
inlinestatic
Parameters
baseQDC peripheral base address.
Returns
Logical OR'ed value of the status flags, _qdc_status_flags.
static void QDC_ClearStatusFlags ( QDC_Type *  base,
uint16_t  u16Flags 
)
inlinestatic
Parameters
baseQDC peripheral base address.
u16FlagsLogical OR'ed value of the flags to clear, _qdc_status_flags.
static uint16_t QDC_GetSignalStatusFlags ( QDC_Type *  base)
inlinestatic
Parameters
baseQDC peripheral base address.
Returns
Logical OR'ed value of the real-time signal status, _qdc_signal_status.
static qdc_count_direction_flag_t QDC_GetLastCountDirection ( QDC_Type *  base)
inlinestatic
Parameters
baseQDC peripheral base address.
Returns
Direction of the last count.
static void QDC_EnableInterrupts ( QDC_Type *  base,
uint16_t  u16Interrupts 
)
inlinestatic
Parameters
baseQDC peripheral base address.
u16InterruptsLogical OR'ed value of the interrupts, _qdc_interrupt_enable.
static void QDC_DisableInterrupts ( QDC_Type *  base,
uint16_t  u16Interrupts 
)
inlinestatic
Parameters
baseQDC peripheral base address.
u32InterruptsLogical OR'ed value of the interrupts, _qdc_interrupt_enable.
static void QDC_DoSoftwareLoadInitialPositionValue ( QDC_Type *  base)
inlinestatic

Software trigger to load the initial position value (UINIT and LINIT) contents to position counter (UPOS and LPOS), so that to provide the consistent operation the position counter registers.

Parameters
baseQDC peripheral base address.
static void QDC_SetInitialPositionValue ( QDC_Type *  base,
uint32_t  u32PositionInitValue 
)
inlinestatic

Set the position counter initial value (INIT or UINIT, LINIT).

Parameters
baseQDC peripheral base address
u32PositionInitValuePosition initial value
static void QDC_SetPositionCounterValue ( QDC_Type *  base,
uint32_t  u32PositionCounterValue 
)
inlinestatic

Set the position counter value (POS or UPOS, LPOS).

Parameters
baseQDC peripheral base address
u32PositionCounterValuePosition counter value
static void QDC_SetPositionModulusValue ( QDC_Type *  base,
uint32_t  u32PositionModulusValue 
)
inlinestatic

Set the position counter modulus value (MOD or UMOD, LMOD).

Parameters
baseQDC peripheral base address
u32PositionModulusValuePosition modulus value
static void QDC_SetPositionCompareValue ( QDC_Type *  base,
uint32_t  u32PositionCompValue 
)
inlinestatic

Set the position counter compare value (COMP or UCOMP, LCOMP).

Parameters
baseQDC peripheral base address
u32PositionCompValuePosition modulus value
static void QDC_SetPositionCompare1Value ( QDC_Type *  base,
uint32_t  u32PositionComp1Value 
)
inlinestatic

Set the position counter compare 1 value (COMP1 or UCOMP1, LCOMP1).

Parameters
baseQDC peripheral base address
u32PositionComp1ValuePosition modulus value
static uint32_t QDC_GetPosition ( QDC_Type *  base)
inlinestatic
Parameters
baseQDC peripheral base address.
Returns
Current position counter's value.
static uint32_t QDC_GetHoldPosition ( QDC_Type *  base)
inlinestatic

The position counter (POS or UPOS, LPOS) value is loaded to hold position (POSH or UPOSH, LPOSH) when:

  1. Position register (POS or UPOS, LPOS), or position difference register (POSD), or revolution register (REV) is read.
  2. TRIGGER happens and TRIGGER is enabled to update the hold registers.
Parameters
baseQDC peripheral base address.
Returns
Hold position counter's value.
static uint16_t QDC_GetPositionDifference ( QDC_Type *  base)
inlinestatic
Parameters
baseQDC peripheral base address.
Returns
The position difference counter's value.
static uint16_t QDC_GetHoldPositionDifference ( QDC_Type *  base)
inlinestatic

The position difference (POSD) value is loaded to hold position difference (POSDH) when:

  1. Position register (POS or UPOS, LPOS), or position difference register (POSD), or revolution register (REV) is read. When Period Measurement is enabled (CTRL3[PMEN] = 1), POSDH will only be udpated when reading POSD.
  2. TRIGGER happens and TRIGGER is enabled to update the hold registers.
Parameters
baseQDC peripheral base address.
Returns
Hold position difference counter's value.
static uint16_t QDC_GetRevolution ( QDC_Type *  base)
inlinestatic

Get the revolution counter (REV) value.

Parameters
baseQDC peripheral base address.
Returns
The revolution counter's value.
static uint16_t QDC_GetHoldRevolution ( QDC_Type *  base)
inlinestatic

The revolution counter (REV) value is loaded to hold revolution (REVH) when:

  1. Position register (POS or UPOS, LPOS), or position difference register (POSD), or revolution register (REV) is read.
  2. TRIGGER happens and TRIGGER is enabled to update the hold registers.
Parameters
baseQDC peripheral base address.
Returns
Hold position revolution counter's value.
static uint16_t QDC_GetLastEdgeTime ( QDC_Type *  base)
inlinestatic

Last edge time (LASTEDGE) is the time since the last edge occurred on PHASEA or PHASEB. The last edge time register counts up using the peripheral clock after prescaler. Any edge on PHASEA or PHASEB will reset this register to 0 and start counting. If the last edge timer count reaches 0xffff, the counting will stop in order to prevent an overflow.

Parameters
baseQDC peripheral base address.
Returns
The last edge time.
static uint16_t QDC_GetHoldLastEdgeTime ( QDC_Type *  base)
inlinestatic

The hold of last edge time(LASTEDGEH) is update to last edge time(LASTEDGE) when the position difference register register (POSD) is read.

Parameters
baseQDC peripheral base address.
Returns
Hold of last edge time.
static uint16_t QDC_GetPositionDifferencePeriod ( QDC_Type *  base)
inlinestatic

The Position Difference Period counter (POSDPER) counts up using the prescaled peripheral clock. When reading the position difference register(POSD), the last edge time (LASTEDGE) will be loaded to position difference period counter(POSDPER). If the POSDPER count reaches 0xffff, the counting will stop in order to prevent an overflow. Counting will continue when an edge occurs on PHASEA or PHASEB.

Parameters
baseQDC peripheral base address.
Returns
The position difference period counter value.
static uint16_t QDC_GetBufferedPositionDifferencePeriod ( QDC_Type *  base)
inlinestatic

The Bufferd Position Difference Period (POSDPERBFR) value is updated with the position difference period counter(POSDPER) when any edge occurs on PHASEA or PHASEB.

Parameters
baseQDC peripheral base address.
Returns
The buffered position difference period counter value.
static uint16_t QDC_GetHoldPositionDifferencePeriod ( QDC_Type *  base)
inlinestatic

The hold position difference period(POSDPERH) is updated with the value of buffered position difference period(POSDPERBFR) when the position difference(POSD) register is read.

Parameters
baseQDC peripheral base address.
Returns
The hold position difference period counter value.