S32K3 HardFault Error

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

S32K3 HardFault Error

753 Views
LZY
Contributor II

Hello, I'm currently encountering a hardfault situation during the development process. The compilation is successful, but as soon as it runs, it enters the hardfault function.
I tried two approaches to solve it, but I didn't find the root cause of the problem.


Approach one: Move some global variables to ".dtcm_data",
eg.

__attribute__((section(".dtcm_data"))) Service_SocComm_TxSubCmd_t AppTxSub_0xDB_Cmd[] =
{
    TX_SUBCMD_STRUCT(MCU_SOC_0XDB01_CMD,FRAME_TYPE_IMMEDIATELY,ACK_NO,200u,0u,0x00u),
};


Method Two: Remove the const modifier from some global variables that were originally defined as const.
Could you please infer the cause of the problem?thanks

Labels (3)
Tags (1)
0 Kudos
Reply
1 Reply

680 Views
petervlna
NXP TechSupport
NXP TechSupport

Hello,

In order to resolve hard fault you can simply follow the guide we have posted:

https://community.nxp.com/pwmxy87654/attachments/pwmxy87654/S32K%40tkb/128/1/How%20To%20Debug%20A%20...

Best regards,

Peter

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2331071%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ES32K3%20HardFault%20Error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2331071%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%2C%20I'm%20currently%20encountering%20a%20hardfault%20situation%20during%20the%20development%20process.%20The%20compilation%20is%20successful%2C%20but%20as%20soon%20as%20it%20runs%2C%20it%20enters%20the%20hardfault%20function.%3CBR%20%2F%3EI%20tried%20two%20approaches%20to%20solve%20it%2C%20but%20I%20didn't%20find%20the%20root%20cause%20of%20the%20problem.%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EApproach%20one%3A%20Move%20some%20global%20variables%20to%20%22.dtcm_data%22%2C%3CBR%20%2F%3Eeg.%3C%2FP%3E%3CP%3E__attribute__((section(%22.dtcm_data%22)))%20Service_SocComm_TxSubCmd_t%20AppTxSub_0xDB_Cmd%5B%5D%20%3D%3CBR%20%2F%3E%7B%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20TX_SUBCMD_STRUCT(MCU_SOC_0XDB01_CMD%2CFRAME_TYPE_IMMEDIATELY%2CACK_NO%2C200u%2C0u%2C0x00u)%2C%3CBR%20%2F%3E%7D%3B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EMethod%20Two%3A%20Remove%20the%20const%20modifier%20from%20some%20global%20variables%20that%20were%20originally%20defined%20as%20const.%3CBR%20%2F%3ECould%20you%20please%20infer%20the%20cause%20of%20the%20problem%3Fthanks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2331071%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3EMCXA%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMCXC%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMCXN%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2333272%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20S32K3%20HardFault%20Error%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2333272%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHello%2C%3C%2FP%3E%0A%3CP%3EIn%20order%20to%20resolve%20hard%20fault%20you%20can%20simply%20follow%20the%20guide%20we%20have%20posted%3A%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fwww.google.com%2Furl%3Fsa%3Dt%26amp%3Bsource%3Dweb%26amp%3Brct%3Dj%26amp%3Bopi%3D89978449%26amp%3Burl%3Dhttps%3A%2F%2Fcommunity.nxp.com%2Fpwmxy87654%2Fattachments%2Fpwmxy87654%2FS32K%252540tkb%2F128%2F1%2FHow%252520To%252520Debug%252520A%252520Fault%252520Exception%252520On%252520ARM%252520Cortex-M(V7M)%252520MCU(S32K3XX).pdf%26amp%3Bved%3D2ahUKEwjBneSu56OTAxVH2gIHHUhnIvYQFnoECBUQAQ%26amp%3Busg%3DAOvVaw2wzPbjlZ_MfgQJdmyYUWAL%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fcommunity.nxp.com%2Fpwmxy87654%2Fattachments%2Fpwmxy87654%2FS32K%2540tkb%2F128%2F1%2FHow%2520To%2520Debug%2520A%2520Fault%2520Exception%2520On%2520ARM%2520Cortex-M%2528V7M%2529%2520MCU%2528S32K3XX%2529.pdf%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EBest%20regards%2C%3C%2FP%3E%0A%3CP%3EPeter%3C%2FP%3E%3C%2FLINGO-BODY%3E