Hi,
I am trying to read a PWM signal using eMIOS Input Capture on the MPC5775B, but the captured value is always 0 even though the input signal is present.
Hardware Setup
PWM is generated from an Arduino at 10 kHz
Arduino PWM output is connected to MPC5775B eMIOS Channel 1
Grounds of both boards are connected together
The GPIO pin connected to the eMIOS channel is toggling correctly (verified using an oscilloscope)
Software Configuration (S32 Design Studio)
Global Initialization
EMIOS_DRV_InitGlobal(INST_EMIOS_MC1, &eMIOS_Mc1_InitConfig0);
EMIOS_DRV_MC_CounterStart(INST_EMIOS_MC1, 23);
EMIOS_DRV_EnableGlobalEmios(INST_EMIOS_MC1);
EMIOS_DRV_IC_InitInputCaptureMode(INST_EMIOS_MC1, 1, &eMIOS_Ic1_ICChnConfig0);
Input Capture Read (Polling Mode)
uint32_t value;
status_t status;
while (1)
{
status = EMIOS_DRV_IC_GetLastMeasurement(INST_EMIOS_MC1, 1, &value);
if (status == STATUS_SUCCESS)
{
printf("Captured value: %lu\r\n", value);
}
}No interrupts are being used (polling only).
Configuration Structures
Global Configuration
const emios_common_param_t eMIOS_Mc1_InitConfig0 =
{
.allowDebugMode = false,
.lowPowerMode = false,
.clkDivVal = 1U,
.enableGlobalPrescaler = false,
.enableGlobalTimeBase = false,
.enableExternalTimeBase = false,
.serverTimeSlot = 0U
};
Counter Channel Configuration (Channel 23)
const emios_mc_mode_param_t eMIOS_Mc1_CntChnConfig0 =
{
.mode = EMIOS_MODE_MC_UP_CNT_CLR_START_INT_CLK,
.period = 10000UL,
.internalPrescaler = EMIOS_CLOCK_DIVID_BY_1,
.internalPrescalerEn = true,
.filterInput = EMIOS_INPUT_FILTER_BYPASS,
.filterEn = false,
.triggerMode = EMIOS_TRIGGER_EDGE_FALLING
};
Input Capture Configuration (Channel 1)
const emios_input_capture_param_t eMIOS_Ic1_ICChnConfig0 =
{
.mode = EMIOS_MODE_IC,
.timebase = EMIOS_BUS_SEL_A,
.filterInput = EMIOS_INPUT_FILTER_BYPASS,
.filterEn = false,
.inputCaptureMode = EMIOS_FALLING_EDGE_PERIOD_MEASUREMENT
};
Observations
STATUS_SUCCESS is always returned
Captured value is always 0
The global bus counter is incrementing
The GPIO input pin is toggling correctly
Polling mode is used (no interrupts)
Questions
Why is the captured value always 0 even though the signal is present?
Is there any flag that must be cleared manually before reading the measurement?
Is additional configuration required for proper edge detection?
Any guidance on what might be missing in the configuration would be greatly appreciated.
Thank you.