I am trying to setup the KV58 timer capture for encoder phase A.
I do not see any values in the CnV register.
I am following this post https://community.nxp.com/t5/Kinetis-Microcontrollers/KV5x-How-to-connect-the-encoder-inputs-to-a-ge...
I connected the XBARA11_IN to XBARA42_OUT I setup the timer with this code.
const ftm_config_t FTM1_config = { .prescale = kFTM_Prescale_Divide_8, .faultMode = kFTM_Fault_Disable, .faultFilterValue = 0, .deadTimePrescale = kFTM_Deadtime_Prescale_1, .deadTimeValue = 0, .pwmSyncMode = kFTM_SoftwareTrigger, .reloadPoints = 0, .extTriggers = 0, .chnlInitState = 0, .chnlPolarity = 0, .bdmMode = kFTM_BdmMode_3, .useGlobalTimeBase = false };
static void FTM1_init(void) { FTM_Init(FTM1_PERIPHERAL, &FTM1_config); FTM_SetTimerPeriod(FTM1_PERIPHERAL, FTM1_TIMER_MODULO_VALUE); FTM_SetupInputCapture(FTM1_PERIPHERAL, kFTM_Chnl_1, kFTM_RiseAndFallEdge, 0); FTM_StartTimer(FTM1_PERIPHERAL, kFTM_SystemClock); }
Solved! Go to Solution.
Hi I still have not resolved this
From reading your suggestions I feel I have adequately connected the XBARA_IN11 to the FTM1 Ch1 edge capture.
Is it possible I have a conflict with some other device, I am using PIT Timers.
Is this the correct XBARA Output?
Is this not being setup through the fsl hal layer stuff?
t appears that you've set up the FTM (FlexTimer Module) correctly, but you haven't mentioned how you're connecting the XBARA (Crossbar Switch) and configuring it.
To route the encoder signal through the XBARA and to the FTM input capture, you need to set up the XBARA as well. Here's an example of how to do that:
CLOCK_EnableClock(kCLOCK_XbarA);
XBARA_Init(XBARA);
XBARA_SetSignalsConnection(XBARA, kXBARA1_InputQdtimer1Trig01, kXBARA1_OutputXbOut11);
XBARA_SetSignalsConnection(XBARA, kXBARA1_InputXbIn42, kXBARA1_OutputFtm1Ch1);
static void FTM1_init(void) {
// Enable the XBARA clock
CLOCK_EnableClock(kCLOCK_XbarA);
// Initialize the XBARA module
XBARA_Init(XBARA);
// Connect the input signal (Phase A) to XBARA_IN11
XBARA_SetSignalsConnection(XBARA, kXBARA1_InputQdtimer1Trig01, kXBARA1_OutputXbOut11);
// Connect XBARA_OUT42 to FTM1_CH1 input
XBARA_SetSignalsConnection(XBARA, kXBARA1_InputXbIn42, kXBARA1_OutputFtm1Ch1);
// Initialize the FTM1 module with the given configuration
FTM_Init(FTM1_PERIPHERAL, &FTM1_config);
// Set the timer period
FTM_SetTimerPeriod(FTM1_PERIPHERAL, FTM1_TIMER_MODULO_VALUE);
// Setup the input capture
FTM_SetupInputCapture(FTM1_PERIPHERAL, kFTM_Chnl_1, kFTM_RiseAndFallEdge, 0);
// Start the timer
FTM_StartTimer(FTM1_PERIPHERAL, kFTM_SystemClock);
}
Hi I still have not resolved this
From reading your suggestions I feel I have adequately connected the XBARA_IN11 to the FTM1 Ch1 edge capture.
Is it possible I have a conflict with some other device, I am using PIT Timers.
Is this the correct XBARA Output?
Is this not being setup through the fsl hal layer stuff?
Sorry, I failed to post what I had for XBARA
This is what I had(lots setup by MCUespresso)
The encoder is on Pin 71 which can be routed to XB_IN11
XBARA_Init(XBARA);