Hardfault when we are not using debugger in S32K344

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

Hardfault when we are not using debugger in S32K344

Jump to solution
516 Views
MVR
Contributor V

Hello everyone,

I'm facing a weird issue. When I run my code in the debug mode, everything works properly (CAN, UART and so on).

But when I remove the debugger and reset the board, I can see that the CAN and other peripherals don't work as I expected.

Then, I attached the debugger activating this option:

MVR_0-1755031791882.png

And I could see that the system reaches the hardfault:

MVR_1-1755032079675.png

Before, I was facing the same issue (with debugger) and I could find out that the problem was the Interrupt Monitor into the Platform_Init(), when I removed this configuration on Tresos 29.0.0 (disable the INTM), I started to get hardfault in this new point into Mcl_Init(), showed below.

Also, I could see that if I commented out the Mcl_init(), I get hardfault as well in the Uart_Init(), in this point:

MVR_3-1755032834466.png

Again, using the system in debug mode, it doesn't happened. Can anyone help me with this problem? 

I could see some topics related this issue and the people saying that HSE_CLK should be CORE_CLK/2, but it is already configured this way:

MVR_2-1755032234658.png

Thank you,

MVR

0 Kudos
Reply
1 Solution
461 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@MVR

I tested your code, you need to use "MCU_SetMode()" to turn on the peripheral clock, this is the reason for entering hardfault

Senlent_0-1755160640927.png

 

View solution in original post

0 Kudos
Reply
3 Replies
491 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@MVR

"When I run my code in the debug mode, everything works properly (CAN, UART and so on)."

Most of these problems should be related to the clock configuration.

If you can provide a complete project, I can help you check it.

0 Kudos
Reply
482 Views
MVR
Contributor V

Sent you via private message due to confidentiality...

But as soon as we fixed this issue, I will post the solution here to help the community.

Thanks.

0 Kudos
Reply
462 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@MVR

I tested your code, you need to use "MCU_SetMode()" to turn on the peripheral clock, this is the reason for entering hardfault

Senlent_0-1755160640927.png

 

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2151143%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EHardfault%20when%20we%20are%20not%20using%20debugger%20in%20S32K344%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2151143%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%20everyone%2C%3C%2FP%3E%3CP%3EI'm%20facing%20a%20weird%20issue.%20When%20I%20run%20my%20code%20in%20the%20debug%20mode%2C%20everything%20works%20properly%20(CAN%2C%20UART%20and%20so%20on).%3C%2FP%3E%3CP%3EBut%20when%20I%20remove%20the%20debugger%20and%20reset%20the%20board%2C%20I%20can%20see%20that%20the%20CAN%20and%20other%20peripherals%20don't%20work%20as%20I%20expected.%3C%2FP%3E%3CP%3EThen%2C%20I%20attached%20the%20debugger%20activating%20this%20option%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22MVR_0-1755031791882.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22MVR_0-1755031791882.png%22%20style%3D%22width%3A%20381px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F352056i59F2F809534D1AE0%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22MVR_0-1755031791882.png%22%20alt%3D%22MVR_0-1755031791882.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EAnd%20I%20could%20see%20that%20the%20system%20reaches%20the%20hardfault%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22MVR_1-1755032079675.png%22%20style%3D%22width%3A%20449px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22MVR_1-1755032079675.png%22%20style%3D%22width%3A%20449px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F352059i8E44BE09F33A891C%2Fimage-dimensions%2F449x98%3Fv%3Dv2%22%20width%3D%22449%22%20height%3D%2298%22%20role%3D%22button%22%20title%3D%22MVR_1-1755032079675.png%22%20alt%3D%22MVR_1-1755032079675.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EBefore%2C%20I%20was%20facing%20the%20same%20issue%20(with%20debugger)%20and%20I%20could%20find%20out%20that%20the%20problem%20was%20the%20Interrupt%20Monitor%20into%20the%20Platform_Init()%2C%20when%20I%20removed%20this%20configuration%20on%20Tresos%2029.0.0%20(disable%20the%20INTM)%2C%20I%20started%20to%20get%20hardfault%20in%20this%20new%20point%20into%20Mcl_Init()%2C%20showed%20below.%3C%2FP%3E%3CP%3EAlso%2C%20I%20could%20see%20that%20if%20I%20commented%20out%20the%20Mcl_init()%2C%20I%20get%20hardfault%20as%20well%20in%20the%20Uart_Init()%2C%20in%20this%20point%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22MVR_3-1755032834466.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22MVR_3-1755032834466.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F352069iECC068E97DC73706%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22MVR_3-1755032834466.png%22%20alt%3D%22MVR_3-1755032834466.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EAgain%2C%20using%20the%20system%20in%20debug%20mode%2C%20it%20doesn't%20happened.%20Can%20anyone%20help%20me%20with%20this%20problem%3F%26nbsp%3B%3C%2FP%3E%3CP%3EI%20could%20see%20some%20topics%20related%20this%20issue%20and%20the%20people%20saying%20that%20HSE_CLK%20should%20be%20CORE_CLK%2F2%2C%20but%20it%20is%20already%20configured%20this%20way%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22MVR_2-1755032234658.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22MVR_2-1755032234658.png%22%20style%3D%22width%3A%20377px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F352061i2B892A2050E7B52E%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22MVR_2-1755032234658.png%22%20alt%3D%22MVR_2-1755032234658.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EThank%20you%2C%3C%2FP%3E%3CP%3EMVR%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2152227%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Hardfault%20when%20we%20are%20not%20using%20debugger%20in%20S32K344%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2152227%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%40%3CSPAN%3EMVR%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EI%20tested%20your%20code%2C%20you%20need%20to%20use%20%22MCU_SetMode()%22%20to%20turn%20on%20the%20peripheral%20clock%2C%20this%20is%20the%20reason%20for%20entering%20hardfault%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%22Senlent_0-1755160640927.png%22%20style%3D%22width%3A%20454px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Senlent_0-1755160640927.png%22%20style%3D%22width%3A%20454px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F352413i12011E59068318C7%2Fimage-dimensions%2F454x245%3Fv%3Dv2%22%20width%3D%22454%22%20height%3D%22245%22%20role%3D%22button%22%20title%3D%22Senlent_0-1755160640927.png%22%20alt%3D%22Senlent_0-1755160640927.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2151678%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Hardfault%20when%20we%20are%20not%20using%20debugger%20in%20S32K344%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2151678%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3ESent%20you%20via%20private%20message%20due%20to%20confidentiality...%3C%2FP%3E%3CP%3EBut%20as%20soon%20as%20we%20fixed%20this%20issue%2C%20I%20will%20post%20the%20solution%20here%20to%20help%20the%20community.%3C%2FP%3E%3CP%3EThanks.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2151359%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20Hardfault%20when%20we%20are%20not%20using%20debugger%20in%20S32K344%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2151359%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CA%20href%3D%22mailto%3AHi%40MVR%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EHi%40MVR%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%22%3CSPAN%3EWhen%20I%20run%20my%20code%20in%20the%20debug%20mode%2C%20everything%20works%20properly%20(CAN%2C%20UART%20and%20so%20on).%3C%2FSPAN%3E%22%3C%2FP%3E%0A%3CP%3EMost%20of%20these%20problems%20should%20be%20related%20to%20the%20clock%20configuration.%3C%2FP%3E%0A%3CP%3EIf%20you%20can%20provide%20a%20complete%20project%2C%20I%20can%20help%20you%20check%20it.%3C%2FP%3E%3C%2FLINGO-BODY%3E