ECAP Capture PWM
Brief
Capture period and duty cycle of PWM
Details
This example demonstrates capturing of period and duty cycle of PWM signals using the Enhanced Capture (ECAP) module. An MCPWM module generates test PWM signals with various frequencies and duty cycles ECAP captures timestamps on to measure High time, Low time, Total period, Duty cycle percentage
Signal Routing: The PWM output is looped back externally through GPIO pin to the ECAP module via INPUTXBAR PWM1A (a GPIO) -> External loopback connection -> GPIO -> INPUTXBAR -> ECAP
Test Cases: The example runs 10 different test cases with varying PWM configurations:
Frequencies: 1kHz to 100kHz
Duty cycles: 10% to 90%
Validation: Measured values are compared against expected values with a ±5% tolerance, and results are logged
Peripherals used
ECAP
Instance : APP_ECAP
Input : APP_INPUTXBAR
Mode : Capture
Clk : 250MHz
Edges : R F R
Interrupt : On event3
INPUTXBAR
Instance : APP_INPUTXBAR
Src : GPIO - GPIO_CAPTURE_SIGNAL
Dest : ECAP - APP_ECAP
MCPWM
Instance : APP_MCPWM
Channels Enabled: 1A
Time Base
TB Clk : 250MHz
Counter Mode : UpCount
PRD (initial) : 19999. Freq: 12.5KHz
PWM 1
CMPA (initial): 5000 cycles / 25%%
Actions 1A : High on Zero. Low on CMPA hit
GPIO
Pin: GPIO_CAPTURE_SIGNAL_PIN
Direction: Input
External connections
PWM pin to GPIO pin loopback
Connect: BoosterPack header J4 pin 40 to BoosterPack header J2 pin 11
LED Details: PASS LED (LED5), FAIL LED (LED4)
Connect: HSEC PIN 58 (PB3) to HSEC PIN 27 (PA3)
LED Details: PASS LED (D4), FAIL LED (D3)