EQEP Frequency Measurement

Brief

Frequency measurement using EQEP (FR and PR methods)

Details

This example demonstrates frequency measurement using the EQEP (Enhanced Quadrature Encoder Pulse) peripheral. The example measures frequency using two independent methods:

  • FR (Frequency Register) Method: Counts position changes over a fixed time window

  • PR (Period Register) Method: Calculates frequency from capture period measurements

The MCPWM peripheral generates a test signal which is routed to EQEP via INPUTXBAR for measurement.

Block diagram Block diagram (pins applicable for LaunchPad)

Sequence

  • Enable test signal generation (MCPWM) and EQEP counter

  • Measure frequency using FR method

    • Wait for 3 consecutive measurements to stabilize

  • Measure frequency using PR method

    • Single measurement from capture period

  • Validate both measurements against expected frequency

Signal Routing: The PWM output is looped back externally through GPIO pins to the EQEP module via INPUTXBAR MCPWM -> GPIO -> External loopback connection -> GPIO -> INPUTXBAR -> EQEP

Validation

  • FR Frequency: Measured vs. expected frequency within ±5%

  • PR Frequency: Measured vs. expected frequency within ±5%

  • Status Indicators:

    • PASS LED turns on if no errors

    • FAIL LED turns on if errors detected

  • Detailed log shows results for both measurement methods

Peripherals used

EQEP
  Instance          : APP_EQEP

    Frequency Register (FR) Method
      Unit Timer Period : 250000000 cycles (250 MHz counter)
      Timer Interrupt   : Unit Timeout Event

    Period Register (PR) Method
      Capture Prescale  : 128
      Unit Position Event Prescale : 2

    Inputs
      QEPA (Phase A)  : INPUTXBAR17 -> APP_MCPWM 1A
      QEPB (Phase B)  : INPUTXBAR18 -> APP_MCPWM 2A
      INDEX           : INPUTXBAR19 -> APP_MCPWM 2B

MCPWM
  Instance          : APP_MCPWM
    Channels Enabled: 1A,1B,2A,2B
    TB Clk           : 250MHz / 4 = 62.5MHz
    Counter Mode     : Up-Down
    Period           : 15623 cycles

    PWM 1A
      CMPA           : 7812 cycles
      Action         : High on Zero, Low on Period
    PWM 1B
      CMPA           : 3906 cycles
      Action         : Low on Zero
    PWM 2A
      CMPA           : 7812 cycles
      Action         : Low on Zero, High on CMPA UP, Low on CMPA Down
    PWM 2B
      CMPA           : 3906 cycles
      Action         : Low on Zero

INTERRUPTS
  Instance  : APP_EQEP_INT
    Source  : EQEP (Unit Timeout)
    Handler : APP_EQEP_INT_Handler
    Priority: Default

External connections

PWM pin to GPIO pin loopback

  • Connect: BoosterPack header J4 pin 40 to BoosterPack header J2 pin 11

  • Connect: BoosterPack header J4 pin 38 to BoosterPack header J2 pin 12

  • Connect: BoosterPack header J4 pin 37 to BoosterPack header J2 pin 13

LED Details: PASS LED (LED5), FAIL LED (LED4)