Issue with FTM2_CH0 (PTD0) and FTM2_CH2 (PTE4) Input Capture – Control Ends Up in DefaultISR

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Issue with FTM2_CH0 (PTD0) and FTM2_CH2 (PTE4) Input Capture – Control Ends Up in DefaultISR

939 次查看
nik007
Contributor I

Hi everyone,

I am trying to configure FTM2_CH0 (PTD0) and FTM2_CH2 (PTE4) for interrupt-based input capture on an S32K144. However, whenever I provide an input signal, the execution ends up in DefaultISR instead of the expected interrupt handler.

Additionally, when I attempt to set the channel mode using FTM_IC_DRV_SetChannelMode(), the control again ends up in DefaultISR.

I have attached my code, clock configuration, and the test function that I am using in main().

Any insights on what might be causing this issue would be greatly appreciated!

Thanks in advance!

标记 (3)
0 项奖励
回复
2 回复数

904 次查看
_Leo_
NXP TechSupport
NXP TechSupport

Hi,

Thank you so much for your interest in our products and for using our community.

Seems that you are not using RTDs. In such case please refer to AN5303: Features and Operation Modes of FlexTimer Module on S32K and to its respective associated file AN5303SW.

Please test it with the following SW:
- S32 Design Studio (S32DS) for ARM 2.2
- S32 Software Development Kit (SDK) for S32K1xx 3.0.3

On the other hand, we recommend you to use our last SW (S32DS 3.6 and RTD 2.0.0). Where you can find multiple Input Capture Unit (ICU) examples:

2025-03-13_15-36-54.png

Hope it helps you.

Have a nice day!

 

0 项奖励
回复

837 次查看
nik007
Contributor I
Hi,

I am trying to measure frequency using FTM without triggering interrupt for each rising edge. I am measuring 2 signals on PTD0 and PTE4 using FTM0 CH2 and FTM2 CH2 respectively.
Should I mux PTD0 and PTE4 to clk of FTM0 and FTM2 respectively? or to the channels?
I have above configuration for pins and ftm.

I am using ftm3 for polling the ftm0 and ftm2.
I am not getting correct values for pulse_count in the handler.

For testing I am supplying PTD0 with 1khz, 3vpp and 1.5v offset signal.
I doubt gpio is not mapped correctly.

#define INST_FTM_MEASURE_IN1 0U
#define INST_FTM_MEASURE_IN2 2U
#define INST_TIMER_TICK 3U

static pin_settings_config_t g_gpio_mux_config[] = {
{
.base = PORTD,
.pinPortIdx = 0,
.pullConfig = PORT_INTERNAL_PULL_NOT_ENABLED,
.driveSelect = PORT_LOW_DRIVE_STRENGTH,
.passiveFilter = false,
.mux = PORT_MUX_ALT2,
.pinLock = false,
.intConfig = PORT_DMA_INT_DISABLED,
.clearIntFlag = false,
.gpioBase = NULL,
.digitalFilter = false,
},
{
.base = PTE,
.pinPortIdx = 4,
.pullConfig = PORT_INTERNAL_PULL_NOT_ENABLED,
.driveSelect = PORT_LOW_DRIVE_STRENGTH,
.passiveFilter = false,
.mux = PORT_MUX_ALT4,
.pinLock = false,
.intConfig = PORT_DMA_INT_DISABLED,
.clearIntFlag = false,
.gpioBase = NULL,
.digitalFilter = false,
},

}


static ftm_user_config_t ftmICConfig = {
.syncMethod = {
},
.ftmMode =FTM_MODE_INPUT_CAPTURE, /* Mode of operation for FTM */
.ftmPrescaler =FTM_CLOCK_DIVID_BY_64, /* FTM clock prescaler */
.ftmClockSource =FTM_CLOCK_SOURCE_EXTERNALCLK, /* FTM clock source */
.BDMMode =FTM_BDM_MODE_01, /* FTM debug mode */
.isTofIsrEnabled =false, /* Interrupt state */
.enableInitializationTrigger =true /* Initialization trigger */
};


static ftm_input_ch_param_t ftmICChannelConfig_IN = {
2, /* Channel id */
FTM_EDGE_DETECT, /* Input capture operation mode */
FTM_RISING_EDGE, /* Edge alignment mode */
FTM_NO_MEASUREMENT, /* Signal measurement operation type */
3U, /* Filter value */
true, /* Filter state (enabled/disabled) */
false, /* Continuous measurement state */
NULL, /* Vector of callbacks parameters for channels events */
NULL /* Vector of callbacks for channels events */

};

static ftm_input_param_t ftmICParamConfig = {
1U, /* Number of channel configurations */
0xFFFF, /* Maximum count value */
&ftmICChannelConfig_IN /* Channels configuration*/
};

static ftm_user_config_t ftmTickConfig = {
.syncMethod = {
.softwareSync = true, /* Software trigger state */
.hardwareSync0 = false, /* Hardware trigger 1 state */
.hardwareSync1 = false, /* Hardware trigger 2 state */
.hardwareSync2 = false,
.maxLoadingPoint = false,
.minLoadingPoint = false,
.inverterSync = FTM_SYSTEM_CLOCK,
.outRegSync = FTM_SYSTEM_CLOCK,
.maskRegSync = FTM_SYSTEM_CLOCK,
.initCounterSync = FTM_SYSTEM_CLOCK,
.autoClearTrigger = false,
.syncPoint = FTM_UPDATE_NOW /* Synchronization point */
},
.ftmMode = FTM_MODE_UP_TIMER, /* Mode of operation for FTM */
.ftmPrescaler = FTM_CLOCK_DIVID_BY_128, /* FTM clock prescaler */
.ftmClockSource = FTM_CLOCK_SOURCE_EXTERNALCLK,
.BDMMode = FTM_BDM_MODE_00,
.isTofIsrEnabled = true,
.enableInitializationTrigger = false
};

/* Timer mode configuration for flexTimer_mc_1 TimerConfig 0 */
static ftm_timer_param_t ftmTimerModeConfig = {
FTM_MODE_UP_TIMER, /* Counter mode */
0, /* Initial counter value */
37500 /* Final counter value */
};


int main()
{

SystemClockInit();
FTM_DRV_Init(3, &ftmTickConfig, &ftmStateTick);

FTM_DRV_Init(INST_FTM_MEASURE_IN1, &ftmICConfig, &state_ess);
FTM_DRV_Init(INST_FTM_MEASURE_IN2, &ftmICConfig, &state_isens);

FTM_DRV_InitInputCapture(INST_FTM_MEASURE_IN1, &ftmICParamConfig_ESS);
FTM_DRV_InitInputCapture(INST_FTM_MEASURE_IN2, &ftmICParamConfig_ISENS);

FTM_DRV_InitCounter(INST_TIMER_TICK, &ftmTimerModeConfig);
FTM_DRV_CounterStart(INST_TIMER_TICK);

while(1)
{


}

}


void FTM3_Ovf_Reload_IRQHandler(void)
{
in1_pulse_count = FTM_DRV_GetCounter(FTM0);
in1_pulse_count = FTM_DRV_GetCounter(FTM2);

FTM_DRV_SetCounter(FTM0, 0);
FTM_DRV_SetCounter(FTM2, 0);
FTM_DRV_ClearStatusFlags(INST_TIMER_TICK, (uint32_t)FTM_TIME_OVER_FLOW_FLAG);
}

0 项奖励
回复