S32K142 PWM Signal input reading

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S32K142 PWM Signal input reading

103 Views
nirmal_masilamani
Contributor V

Hello Team,

Is there any example available for PWM reading in S32K142 using FTM input capture?

If yes, please share the example.

Tags (1)
0 Kudos
Reply
4 Replies

75 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hello @nirmal_masilamani,

You can refer to:

You can also refer to some community posts:

Hope this helps.

Best regards,
Julián

  •  
0 Kudos
Reply

66 Views
nirmal_masilamani
Contributor V

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?

0 Kudos
Reply

55 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

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.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

0 Kudos
Reply

22 Views
nirmal_masilamani
Contributor V

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

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2410575%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ES32K142%20PWM%20Signal%20input%20reading%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2410575%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%20Team%2C%3C%2FP%3E%3CP%3EIs%20there%20any%20example%20available%20for%20PWM%20reading%20in%20S32K142%20using%20FTM%20input%20capture%3F%3C%2FP%3E%3CP%3EIf%20yes%2C%20please%20share%20the%20example.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2410815%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20S32K142%20PWM%20Signal%20input%20reading%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2410815%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F200831%22%20target%3D%22_blank%22%3E%40Juli%C3%A1n_Arag%C3%B3nM%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%3CP%3EThank%20you%20so%20much%20for%20quick%20reply.%3C%2FP%3E%3CP%3EOne%20small%20doubt%2C%20can%20i%20use%20single%20CH%20to%20measure%20both%20duty%20cycle%20and%20period%3F%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20i%20set%20input%20capture%20mode%20as%20DETECT%20BOTH%20EDGE.%20What%20measurement%20value%20i%20will%20get%20from%26nbsp%3B%3CSTRONG%3EIC_GetMeasurement%3C%2FSTRONG%3E%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2410718%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20S32K142%20PWM%20Signal%20input%20reading%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2410718%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F233316%22%20target%3D%22_blank%22%3E%40nirmal_masilamani%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3EYou%20can%20refer%20to%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3EExample%204.%3C%2FSTRONG%3E%20from%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fwww.nxp.com%2Fdocs%2Fen%2Fapplication-note%2FAN5303.pdf%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EAN5303%3A%20Features%20and%20Operation%20Modes%20of%20FlexTimer%20Module%20on%20S32K%20%E2%80%93%20Application%20Note%3C%2FA%3E.%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EExample%26nbsp%3B2.5%20Timed%20I%2FO%20(FTM)%3C%2FSTRONG%3E%20from%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fwww.nxp.com%2Fdocs%2Fen%2Fapplication-note%2FAN5413.pdf%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EAN5413%3A%20S32K1xx%20Series%20Cookbook%20%E2%80%93%20Application%20Note%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3EFtm_Icu_Ip_BlinkLed_S32K144%20example%20from%20RTD%20package%20(uses%26nbsp%3B%3CSPAN%3EFtm_Icu_Ip_EnableEdgeDetection%20API)%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3Eic_pal%20%26amp%3B%26nbsp%3Bftm_signal_measurement%20examlpes%20from%20SDK%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%3EYou%20can%20also%20refer%20to%20some%20community%20posts%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2FS32K%2Fs32k1-How-to-measure-PWM-frequency-and-duty-cycle-on-the-same%2Ftd-p%2F2190078%22%20target%3D%22_blank%22%3Es32k1%EF%BC%9AHow%20to%20measure%20PWM%20frequency%20and%20duty%20cycle%20on%20the%20same%20FTM%20channel%3C%2FA%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2FS32K%2FS32K-Input-Capture%2Fm-p%2F2252941%22%20target%3D%22_blank%22%3ES32K%20Input%20Capture%3C%2FA%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2FS32K-Knowledge-Base%2FS32K1-Calculate-the-motor-speed-based-on-the-FTM%2Fta-p%2F1515933%22%20target%3D%22_blank%22%3ES32K1-Calculate%20the%20motor%20speed%20based%20on%20the%20FTM%3C%2FA%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%3EHope%20this%20helps.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EBest%20regards%2C%3CBR%20%2F%3EJuli%C3%A1n%3C%2FSPAN%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%26nbsp%3B%3C%2FLI%3E%0A%3C%2FUL%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2411099%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20S32K142%20PWM%20Signal%20input%20reading%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2411099%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F233316%22%20target%3D%22_blank%22%3E%40nirmal_masilamani%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EInput%20capture%20supports%203%20modes%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSPAN%3ECapture%20on%20Rising%20Edge%20Only%20-%26gt%3B%20period%20only%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3ECapture%20on%20Falling%20Edge%20Only%20-%26gt%3B%20period%20only%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3E%3CSPAN%3ECapture%20on%20Rising%20or%20Falling%20Edge%20-%26gt%3B%20Need%20to%20read%20the%20level%20status%20through%20GPIO%20or%20CnSC%20%5BCHIS%5D%20bit%20to%20know%20the%20high-level%20pulse%20width%20or%20the%20low-level%20pulse%20width.%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%3E%3CSTRONG%3ENOTE%3A%3C%2FSTRONG%3E%20The%20CHIS%20bit%20should%20be%20ignored%20when%20the%20channel%20(n)%20is%20not%20in%20an%20input%20mode.%3CBR%20%2F%3E%3CSTRONG%3ENOTE%3A%3C%2FSTRONG%3E%20When%20the%20pair%20channels%20is%20on%20dual%20edge%20mode%2C%20the%20channel%20(n%2B1)%20CHIS%20bit%20is%20the%20channel%20(n%2B1)%20input%20value%20and%20not%20the%20channel%20(n)%20input%20value%20(this%20signal%20is%20the%20input%20signal%20used%20by%20the%20dual%20edge%20mode).%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EFor%20PWM%20duty%20cycle%20capture%2C%20you%20should%20use%20dual%20edge%20capture.%26nbsp%3BOtherwise%2C%20you%20will%20only%20get%20the%20period%20of%20high%20level%20or%20low%20level.%20In%20the%20dual%20edge%20capture%20mode%2C%20only%20channel%20(n)%20input%20is%20used%20and%20channel%20(n%2B1)%20input%20is%20ignored.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Julin_AragnM_0-1788457862022.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Julin_AragnM_0-1788457862022.png%22%20style%3D%22width%3A%20789px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Julin_AragnM_0-1788457862022.png%22%20style%3D%22width%3A%20789px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F395881i8689084ABF920637%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Julin_AragnM_0-1788457862022.png%22%20alt%3D%22Julin_AragnM_0-1788457862022.png%22%20%2F%3E%3Cspan%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EJulin_AragnM_0-1788457862022.png%3C%2Fspan%3E%3C%2Fspan%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EJulin_AragnM_0-1788457862022.png%3C%2FSPAN%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EJulin_AragnM_0-1788457862022.png%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EIC_GetMeasurement%20will%20return%20the%20pulse%20width%20in%20ticks%2C%20which%20you%20can%20then%20use%20to%20calculate%20signal%20frequency%3A%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-c%22%3E%3CCODE%3E%2F*%20Get%20the%20latest%20value%20*%2F%0AinputCaptureMeas%20%3D%20IC_GetMeasurement(%26amp%3Bic_pal_1_instanceConfig%2C%20channel)%3B%0A%2F*%20Calculate%20the%20signal%20frequency%20using%20recorded%20data*%2F%0AinputCaptureMeas%20%3D%20frequency%20%2F%20(inputCaptureMeas)%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CBR%20%2F%3E%0A%3CP%3EBest%20regards%2C%3CBR%20%2F%3EJuli%C3%A1n%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2411527%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20S32K142%20PWM%20Signal%20input%20reading%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2411527%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F200831%22%20target%3D%22_blank%22%3E%40Juli%C3%A1n_Arag%C3%B3nM%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%3CP%3EThank%20you%20for%20reply.%3C%2FP%3E%3CP%3EI%20am%20still%20little%20confused.%3C%2FP%3E%3CP%3ETo%20measure%20PWM%20signal%2C%20how%20many%20pins%20i%20need%3F%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20using%20IC_PAL%20for%20measuring.%20But%20i%20am%20unable%20to%20measure%20PWM%20using%20signal%20pin%20and%20single%20ch.%3C%2FP%3E%3CP%3ERTD%20used%20V4.0.0%3C%2FP%3E%3C%2FLINGO-BODY%3E