S32K142 PWM Signal input reading Hello Team, Is there any example available for PWM reading in S32K142 using FTM input capture? If yes, please share the example. Re: S32K142 PWM Signal input reading Hello @Julián_AragónM , Thank you so much for quick reply. One small doubt, can i use single CH to measure both duty cycle and period? If i set input capture mode as DETECT BOTH EDGE. What measurement value i will get from IC_GetMeasurement? Re: S32K142 PWM Signal input reading Hello @nirmal_masilamani,
You can refer to:
Example 4. from AN5303: Features and Operation Modes of FlexTimer Module on S32K – Application Note.
Example 2.5 Timed I/O (FTM) from AN5413: S32K1xx Series Cookbook – Application Note
Ftm_Icu_Ip_BlinkLed_S32K144 example from RTD package (uses Ftm_Icu_Ip_EnableEdgeDetection API)
ic_pal & ftm_signal_measurement examlpes from SDK
You can also refer to some community posts:
s32k1:How to measure PWM frequency and duty cycle on the same FTM channel
S32K Input Capture
S32K1-Calculate the motor speed based on the FTM
Hope this helps.
Best regards, Julián
Re: S32K142 PWM Signal input reading Hello @nirmal_masilamani,
Input capture supports 3 modes:
Capture on Rising Edge Only -> period only
Capture on Falling Edge Only -> period only
Capture on Rising or Falling Edge -> Need to read the level status through GPIO or CnSC [CHIS] bit to know the high-level pulse width or the low-level pulse width.
NOTE: The CHIS bit should be ignored when the channel (n) is not in an input mode. NOTE: When the pair channels is on dual edge mode, the channel (n+1) CHIS bit is the channel (n+1) input value and not the channel (n) input value (this signal is the input signal used by the dual edge mode).
For PWM duty cycle capture, you should use dual edge capture. Otherwise, you will only get the period of high level or low level. In the dual edge capture mode, only channel (n) input is used and channel (n+1) input is ignored.
Julin_AragnM_0-1788457862022.pngJulin_AragnM_0-1788457862022.pngJulin_AragnM_0-1788457862022.png
IC_GetMeasurement will return the pulse width in ticks, which you can then use to calculate signal frequency:
/* Get the latest value */
inputCaptureMeas = IC_GetMeasurement(&ic_pal_1_instanceConfig, channel);
/* Calculate the signal frequency using recorded data*/
inputCaptureMeas = frequency / (inputCaptureMeas);
Best regards, Julián Re: S32K142 PWM Signal input reading Hello @Julián_AragónM , Thank you for reply. I am still little confused. To measure PWM signal, how many pins i need? I am using IC_PAL for measuring. But i am unable to measure PWM using signal pin and single ch. RTD used V4.0.0
View full article