S32K312 put stack in dtcm then run into hardfault

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

S32K312 put stack in dtcm then run into hardfault

166 Views
jhuang1
Contributor I

Hi, I transportted my original program driver to RTD 4.0.0 from RTD 2.0.3. The demo startup file and demo ld file base on RTD 4.0.0 allocate the stack to dtcm area, and I thought it useful to save RAM area. But it resultted in a curious trouble that the program may run into hardfault when it stored some data into a stack addess. 

For example, The stack area address I defined at ld file located at 0x20000000~0x20002000.  I defined a struct data in the pit ISR, which has only 42 bytes, and the address of the struct data was allocated at 0x20001e60 in the pit ISR, once the code runs to "str r0, [r4, #0]" which r4 is 0x20001e60, the program then run into the hardfault. If I move the struct data to globle variable, the ISR would run ok.

Another method to avoid this trouble is disabling the MPU, I think I have some mistake on the MPU setting, the dtcm part setting is as below:

jhuang1_0-1717317569927.png

The ld file is uploaded as attachment.

please help me to check out the trouble, thanks a lot.

 

0 Kudos
4 Replies

108 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

Hi, don't you have some conflict between descriptors' setup?

0 Kudos

106 Views
jhuang1
Contributor I

Hi davidtosenovjan, which descriptors do you mean? 

0 Kudos

104 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

MPU region configurations.

0 Kudos

76 Views
jhuang1
Contributor I

I didn't find any conflict in MPU settings. I changed the stack to sram back, it works fine now.

0 Kudos