Hello,
I am trying to use GPIO6/XINT1 to capture/measure a PWM signal. (ECAP pins are not available)
I am seeing a mismatch between the measurements and what I am expecting based on the TRM and the input at the pin
As a test, I am generating a 10khz PWM signal with 50% duty from EPWM3, and have this connected to GPIO6.
Pulse high time = pulse low time = 50us
Pulse period = 100us
From the TRM, xintctr clock source is SYSCLKOUT
SYSCLK = 60MHz
So my expectation is that the 50us hightime or lowtime would be 3000 counts of a 60MHz clock. Instead I'm seeing a measurement of 50 for hightime and ~227 for lowtime.
At initialization, I first set POLARITY to rising edge only, so I know which edge is being captured. At first capture, I switch POLARITY to both edges. Below is the code used for init and ISR:
Initialization:
EALLOW;
GpioCtrlRegs.GPAMUX1.bit.GPIO6 = 0; // 0=GPIO, 1=EPWM1A, 2=Resv, 3=Resv
GpioCtrlRegs.GPADIR.bit.GPIO6 = 0; // 1=OUTput, 0=INput
GpioIntRegs.GPIOXINT1SEL.bit.GPIOSEL = 6; // GPIO6 as interrupt source
XIntruptRegs.XINT1CR.bit.POLARITY = 0x1; // Trigger on rising edge to start
xint1_startup_flag = true;
XIntruptRegs.XINT1CR.bit.ENABLE = 0x1;
EDIS;
ISR:
if (xint1_startup_flag){
xint1_startup_flag = false;
XIntruptRegs.XINT1CR.bit.POLARITY = 0x3;
xint1_nextedge_is_falling=true;
}
else{
if(xint1_nextedge_is_falling){
xint1_nextedge_is_falling=false;
xint1_pulse_high_time = XIntruptRegs.XINT1CTR; // READING 50, EXPECTING 3000
}
else{
xint1_nextedge_is_falling=true;
xint1_pulse_low_time = XIntruptRegs.XINT1CTR; // READING ~220, EXPECTING 3000
}
}
I confirmed via logic analyzer that the PWM waveform is correct: 50% duty at 10kHz. Test hardware is the LaunchPadXL for the 28027.
Do you have suggestions why I'm getting these measurements instead of the expected values? Or is my interpretation of the datasheet mistaken?
Thanks!