EQEP Position Speed
Brief
Speed measurement using EQEP (FR and PR methods)
Details
This example demonstrates speed measurement using the EQEP (Enhanced Quadrature Encoder Pulse) peripheral. The example measures speed using two independent methods:
FR (Frequency Register) Method: Counts position changes over a fixed time window
PR (Period Register) Method: Calculates speed from capture period measurements
The MCPWM peripheral generates a test signal which is routed to EQEP via INPUTXBAR for measurement.
Sequence
Enable test signal generation (MCPWM) and EQEP counter
Measure speed using FR method
Wait for 3 consecutive measurements to stabilize
Measure speed using PR method
Single measurement from capture period
Validate both measurements against expected speed
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 Speed: Measured vs. expected speed within ±5 RPM
PR Speed: Measured vs. expected speed within ±5 RPM
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)
Connect: HSEC PIN 58 (PB3) to HSEC PIN 27 (PA3)
Connect: HSEC PIN 30 (PA8) to HSEC PIN 80 (PA11)
Connect: HSEC PIN 34 (PA9) to HSEC PIN 82 (PA12)
LED Details: PASS LED (D4), FAIL LED (D3)