Hi,
I am working with FRDM-KE06Z custom board. I have imported ftm_simple_pwm program in to my MCUXpresso IDE and started working on it.
In this code I see that they are using FTM2 and channel 3. And FTM2_IRQn. Like below.
#define BOARD_FTM_BASEADDR FTM2
#define BOARD_FTM_CHANNEL kFTM_Chnl_3
#define FTM_INTERRUPT_NUMBER FTM2_IRQn
#define FTM_LED_HANDLER FTM2_IRQHandler
#define FTM_CHANNEL_INTERRUPT_ENABLE kFTM_Chnl3InterruptEnable
#define FTM_CHANNEL_FLAG kFTM_Chnl3Flag
#define FTM_SOURCE_CLOCK CLOCK_GetFreq(kCLOCK_TimerClk)
and in the main function in the
BOARD_InitPins();
inside BOARD_InitPins(); function they are using corresponsding pin.
PORT_SetPinSelect(kPORT_FTM2CH3, kPORT_FTM2_CH3_PTG5);
When I debug everything is fine.
My question is
I wanted to use FTM1 and Channel 1. Since I want to use FTM1 hence I am using FTM1_IRQn. Like below.
#define BOARD_FTM_BASEADDR FTM1
#define BOARD_FTM_CHANNEL kFTM_Chnl_1
#define FTM_INTERRUPT_NUMBER FTM1_IRQn
#define FTM_LED_HANDLER FTM1_IRQHandler
#define FTM_CHANNEL_INTERRUPT_ENABLE kFTM_Chnl1InterruptEnable
#define FTM_CHANNEL_FLAG kFTM_Chnl1Flag
Also I changed the pin in BOARD_InitPins(); function as below.
PORT_SetPinSelect(kPORT_FTM1CH1, kPORT_FTM1_CH1_PTC5);
When I debug this code my program is hanging. When I made step by step debug I see that when execution goes to the FTM_Init(BOARD_FTM_BASEADDR, &ftmInfo); function, when execution goes to
base->MODE = FTM_MODE_FAULTM(config->faultMode) | FTM_MODE_FTMEN_MASK | FTM_MODE_WPDIS_MASK;
program is hanging all the times.
When I use FTM2 with channel 3 and FTM"_IRQn then it is fine. The problem is only when I use FTM1 and channel1 and FTM1_IRQn.
I should use FTM1 since my prototype uses PTC5 for PWM.
Can someone tell me the problem here?. Thank you.