Hi, Jiri
Thank you for your reply and your test result.
Like the waveform you attached, the output waveform and the input waveform are measured the same.
Again, I'll explain the problem in detail.
EVB_A:
-. Input_A: Set Edge capture
-. Output_A: Set PWM(Period_250us, Duty_50%)
EVB_B:
-. Input_B: Set Edge capture
-. Output_B: Set PWM(Period_250us, Duty_50%)
▶ EVB_A and EVB_B have the same code down.
▶ When Input_A and Output_B are connected, each input and output waveform are same.
▶ To measure the interval, I read the FTM.Cnt value at Edge Capture in EVB_A.
▶ The difference between the FTM.cnt value at the rising edge and the FTM.cnt value at the falling edge is the period.
▶ When Input_A and Output_B are connected, The period obtained through the FTM.cnt value is about 30us.
When Input_A and Output_A are connected, The period obtained through the FTM.cnt value is about 250us.▶ For each connection, the Output_A and Output_B signals are the same waveform with a period of 250us.
However, the difference in FTM.Cnt change rate in EVB_A can not be understood.
In the example code below, "FTM0->CONTROLS[6].CnV It is a difference When Input_A and Output_B are connected.
and When Input_A and Output_A are connected.
<example code: calculate period>
void FTM0_CH6_input_capture(void) {
if (1==((FTM0->CONTROLS[6].CnSC & FTM_CnSC_CHF_MASK)>>FTM_CnSC_CHF_SHIFT)) {
/* If chan flag is set */
FTM0->CONTROLS[6].CnSC &= ~FTM_CnSC_CHF_MASK; /* Clear flag: read reg then set CHF=0 */
PriorCaptureVal = CurrentCaptureVal; /* Record value of prior capture */
CurrentCaptureVal = FTM0->CONTROLS[6].CnV; /* Record value of current capture */
DeltaCapture = CurrentCaptureVal - PriorCaptureVal;
/* Will be 6250 clocks (100 msec) if connected to FTM0 CH0 */
}
}
<example code: FTM0 Init>
void FTM0_init(void) {
PCC->PCCn[PCC_FTM0_INDEX] &= ~PCC_PCCn_CGC_MASK; /* Ensure clk disabled for config */
PCC->PCCn[PCC_FTM0_INDEX] |= PCC_PCCn_PCS(0b001) /* Clock Src=1, 8 MHz SOSCDIV1_CLK */
| PCC_PCCn_CGC_MASK; /* Enable clock for FTM regs */
FTM0->MODE |= FTM_MODE_WPDIS_MASK; /* Write protect to registers disabled (default) */
FTM0->SC = 0x00030000; /* Enable PWM channel 0 output*/
/* Enable PWM channel 1 output*/
/* TOIE (Timer Overflow Interrupt Ena) = 0 (default) */
/* CPWMS (Center aligned PWM Select) = 0 (default, up count) */
/* CLKS (Clock source) = 0 (default, no clock; FTM disabled) */
/* PS (Prescaler factor) = 7. Prescaler = 128 */
FTM0->COMBINE = 0x00000000;/* FTM mode settings used: DECAPENx, MCOMBINEx, COMBINEx=0 */
FTM0->POL = 0x00000000; /* Polarity for all channels is active high (default) */
FTM0->MOD = 62500 -1 ; /* FTM1 counter final value (used for PWM mode) */
/* FTM1 Period = MOD-CNTIN+0x0001 ~= 62500 ctr clks */
/* 8MHz /128 = 62.5kHz -> ticks -> 1Hz */}
}
void FTM0_CH6_IC_init(void) {
FTM0->CONTROLS[6].CnSC = 0x0000000C; /* FTM0 ch6: Input Capture rising or falling edge */
/* CHIE (Chan Interrupt Ena) = 0 (default) */
/* MSB:MSA (chan Mode Select)=0b00, Input Capture */
/* ELSB:ELSA (ch Edge/Level Select)=0b11, rise or fall*/
}