Hello NXP Community,
I'm working on the input capture demo example from the MCUXpresso SDK for i.MX93. By default, the example uses TPM2 Channel 0 (TPM2_CH0) for input capture. I would like to switch this to use TPM3 Channel 2 (TPM3_CH2) instead.
Could you please clarify what all changes need to be made in the SDK code and configuration files to successfully switch the input capture source from TPM2_CH0 to TPM3_CH2?
Here’s what I’ve identified so far:
Update DEMO_TPM_BASEADDR from TPM2 to TPM3.
Update BOARD_TPM_INPUT_CAPTURE_CHANNEL from kTPM_Chnl_0 to kTPM_Chnl_2.
Change the IRQ handler from TPM2_IRQHandler to TPM3_IRQHandler.
Update TPM_INTERRUPT_NUMBER accordingly.
Pin Muxing: I believe the pin for TPM3_CH2 needs to be correctly muxed via IOMUXC. What pin should I use on the i.MX93 EVK or custom board for TPM3_CH2 input?
Are there any additional steps, especially related to:
Clock source setup for TPM3?
Enabling TPM3 module in RDC or CCM?
Input signal routing (XBAR or SAI to TPM)?
Anything specific to i.MX93 SoC or SDK behavior?
Any guidance, especially with respect to clock trees and signal routing for TPM3_CH2, would be highly appreciated.
Thank you!
Hello @Manjunathb
I hope you are doing very well.
I am not sure what SDK version are you using. I tested with the SDK_25_03_00_MCIMX93-EVK.
The changes are:
app.h
/*
* Copyright 2022 NXP
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef _APP_H_
#define _APP_H_
/*******************************************************************************
* Definitions
******************************************************************************/
/*${macro:start}*/
/* define instance */
#define DEMO_TPM_BASEADDR TPM3
/* Interrupt to enable and flag to read; depends on the TPM channel used */
#define BOARD_TPM_INPUT_CAPTURE_CHANNEL kTPM_Chnl_2
/* Interrupt to enable and flag to read; depends on the TPM channel used */
#define TPM_CHANNEL_INTERRUPT_ENABLE kTPM_Chnl2InterruptEnable
#define TPM_CHANNEL_FLAG kTPM_Chnl2Flag
/* Interrupt number and interrupt handler for the TPM instance used */
#define TPM_INTERRUPT_NUMBER TPM3_IRQn
#define TPM_INPUT_CAPTURE_HANDLER TPM3_IRQHandler
/* Get source clock for TPM driver */
#define LPTPM_CLOCK_ROOT kCLOCK_Root_Tpm3
#define LPTPM_CLOCK_GATE kCLOCK_Tpm3
#define TPM_SOURCE_CLOCK CLOCK_GetIpFreq(LPTPM_CLOCK_ROOT)
/*${macro:end}*/
//#define WAKEUP kCLOCK_Root_BusWakeup
/*******************************************************************************
* Prototypes
******************************************************************************/
/*${prototype:start}*/
void BOARD_InitHardware(void);
/*${prototype:end}*/
#endif /* _APP_H_ */
pin_mux.c
void BOARD_InitPins(void) { /*!< Function assigned for the core: undefined[cm33] */
IOMUXC_SetPinMux(IOMUXC_PAD_GPIO_IO12__TPM3_CH2, 0U);
IOMUXC_SetPinMux(IOMUXC_PAD_UART2_RXD__LPUART2_RX, 0U);
IOMUXC_SetPinMux(IOMUXC_PAD_UART2_TXD__LPUART2_TX, 0U);
IOMUXC_SetPinConfig(IOMUXC_PAD_GPIO_IO12__TPM3_CH2,
IOMUXC_PAD_DSE(15U));
IOMUXC_SetPinConfig(IOMUXC_PAD_UART2_RXD__LPUART2_RX,
IOMUXC_PAD_PD_MASK);
IOMUXC_SetPinConfig(IOMUXC_PAD_UART2_TXD__LPUART2_TX,
IOMUXC_PAD_DSE(15U));
}
According to the reference manual, the Pad that you must set to use as TPM3_CH2 is GPIO_IO12:
That pad is exposed in the J1001 in EVK:
Best regards,
Salas.