About the S32k142 timer Capture initializer crash

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

About the S32k142 timer Capture initializer crash

Jump to solution
1,273 Views
Lw2
Contributor III

When I use s32k142, I encounter the abnormal phenomenon of timer capture, hope someone can help to see the reason, thank you here. Let me describe the problem first.

I first explain the code functions: 1, using timer 0 as PWM output 2, using timer 1 as input capture 3, using timer 2 as timing count, 4 using ADC0 ADC1 channel for ADC acquisition

When I initialized the functions of each module in main, all the functions were running normally, as shown in the configuration figure below.

Lw2_0-1725506892198.png

But when I wrap all the initialization into a function and input a PWM signal to any of the capture pins, the running program crashes.

Lw2_2-1725508618243.png

Lw2_3-1725508714099.png

If I block the timer capture configuration, the program works.

Lw2_4-1725508916120.png

What is the cause of this, why the timer capture configuration function into its own wrapped function will crash phenomenon.I have put the source code above, I hope it can be solved, thank you.

 

0 Kudos
Reply
1 Solution
1,208 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @Lw2,

Can you test it with these structures being global not local?

danielmartynek_0-1725970233864.png

 

Thank you,

BR, Daniel

 

View solution in original post

0 Kudos
Reply
2 Replies
1,209 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @Lw2,

Can you test it with these structures being global not local?

danielmartynek_0-1725970233864.png

 

Thank you,

BR, Daniel

 

0 Kudos
Reply
1,148 Views
Lw2
Contributor III

Thank you very much for your reply,BR, Daniel.

After I changed it to a global variable, it worked fine.

Lw2_0-1726637309160.png

Thank you for helping me solve the problem.

%3CLINGO-SUB%20id%3D%22lingo-sub-1947789%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EAbout%20the%20S32k142%20timer%20Capture%20initializer%20crash%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1947789%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EWhen%20I%20use%20s32k142%2C%20I%20encounter%20the%20abnormal%20phenomenon%20of%20timer%20capture%2C%20hope%20someone%20can%20help%20to%20see%20the%20reason%2C%20thank%20you%20here.%20Let%20me%20describe%20the%20problem%20first.%3C%2FP%3E%3CP%3EI%20first%20explain%20the%20code%20functions%3A%201%2C%20using%20timer%200%20as%20PWM%20output%202%2C%20using%20timer%201%20as%20input%20capture%203%2C%20using%20timer%202%20as%20timing%20count%2C%204%20using%20ADC0%20ADC1%20channel%20for%20ADC%20acquisition%3C%2FP%3E%3CP%3EWhen%20I%20initialized%20the%20functions%20of%20each%20module%20in%20main%2C%20all%20the%20functions%20were%20running%20normally%2C%20as%20shown%20in%20the%20configuration%20figure%20below.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Lw2_0-1725506892198.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Lw2_0-1725506892198.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F297228iC877548691DC4154%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Lw2_0-1725506892198.png%22%20alt%3D%22Lw2_0-1725506892198.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EBut%20when%20I%20wrap%20all%20the%20initialization%20into%20a%20function%20and%20input%20a%20PWM%20signal%20to%20any%20of%20the%20capture%20pins%2C%20the%20running%20program%20crashes.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Lw2_2-1725508618243.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Lw2_2-1725508618243.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F297236i03DBFEADF4C71D57%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Lw2_2-1725508618243.png%22%20alt%3D%22Lw2_2-1725508618243.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Lw2_3-1725508714099.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Lw2_3-1725508714099.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F297238i462C46D13CAB8EE3%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Lw2_3-1725508714099.png%22%20alt%3D%22Lw2_3-1725508714099.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EIf%20I%20block%20the%20timer%20capture%20configuration%2C%20the%20program%20works.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Lw2_4-1725508916120.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Lw2_4-1725508916120.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F297239i39480D0033924C0A%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Lw2_4-1725508916120.png%22%20alt%3D%22Lw2_4-1725508916120.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EWhat%20is%20the%20cause%20of%20this%2C%20why%20the%20timer%20capture%20configuration%20function%20into%20its%20own%20wrapped%20function%20will%20crash%20phenomenon.I%20have%20put%20the%20source%20code%20above%2C%20I%20hope%20it%20can%20be%20solved%2C%20thank%20you.%3C%2FP%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1956237%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20About%20the%20S32k142%20timer%20Capture%20initializer%20crash%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1956237%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EThank%20you%20very%20much%20for%20your%20reply%EF%BC%8C%3CSPAN%3EBR%2C%20Daniel.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EAfter%20I%20changed%20it%20to%20a%20global%20variable%2C%20it%20worked%20fine.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Lw2_0-1726637309160.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Lw2_0-1726637309160.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F299591i6D039F3C16FDDD6B%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Lw2_0-1726637309160.png%22%20alt%3D%22Lw2_0-1726637309160.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EThank%20you%20for%20helping%20me%20solve%20the%20problem.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1951095%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20About%20the%20S32k142%20timer%20Capture%20initializer%20crash%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1951095%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F209549%22%20target%3D%22_blank%22%3E%40Lw2%3C%2FA%3E%2C%3C%2FP%3E%0A%3CP%3ECan%20you%20test%20it%20with%20these%20structures%20being%20global%20not%20local%3F%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22danielmartynek_0-1725970233864.png%22%20style%3D%22width%3A%20321px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22danielmartynek_0-1725970233864.png%22%20style%3D%22width%3A%20321px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F298270iAE74E3F341BE2503%2Fimage-dimensions%2F321x87%3Fv%3Dv2%22%20width%3D%22321%22%20height%3D%2287%22%20role%3D%22button%22%20title%3D%22danielmartynek_0-1725970233864.png%22%20alt%3D%22danielmartynek_0-1725970233864.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EThank%20you%2C%3C%2FP%3E%0A%3CP%3EBR%2C%20Daniel%3C%2FP%3E%0A%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E