Hard_Fault during debugging

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

Hard_Fault during debugging

Jump to solution
1,059 Views
armendgecaj
Contributor III

Hi all,

 

i am working with CodeWarrior for MCU v10.6 and with the Kinetis K60F (MK60FN1M0).

I have a question. Maybe someone can give me a hint.

 

If i build my algorithm in CodeWarrior then i get no errors. But if i debugg it then i branch in a hard_fault.

The Problem is, the hard_fault occurs not during the execution of my algorithm. It occurs during downloading my algorithm to my microcontroller. Therefore, it is difficult to find the location where the hard_fault occured.

 

I tried also the 'HardFault' Component from Erich to get the location but it does not help, because my project is not executing.

 

Have someone any idea how to find out the problem?

Or can anybody tell me what can cause a hard_fault during downloading a project?

 

I do not think that the problem is a command in my algorithm because the hard_fault does not occur during the execution.

It have to be something else.

 

I would be grateful for any help.

 

Best Regards

Armend

Labels (1)
0 Kudos
1 Solution
866 Views
armendgecaj
Contributor III

At all.

Finally the problem with my global variable 'Labyrinth[240][320]' is solved.

Now i get no 'hard_fault'.

My idea was this:

I changed the size of my global variable from 240x320 to 24x32. Besides i created a resize factor (=10).

Now each position of my minimized global variable represents a 10x10 array.

I tried it and it works very fine.

Best Regards

Armend

View solution in original post

0 Kudos
5 Replies
867 Views
armendgecaj
Contributor III

At all.

Finally the problem with my global variable 'Labyrinth[240][320]' is solved.

Now i get no 'hard_fault'.

My idea was this:

I changed the size of my global variable from 240x320 to 24x32. Besides i created a resize factor (=10).

Now each position of my minimized global variable represents a 10x10 array.

I tried it and it works very fine.

Best Regards

Armend

0 Kudos
866 Views
TICS_Fiona
NXP Employee
NXP Employee

Hello Armend

First, please open ‘Project Properties’, then go to ‘Run/Debug Settings’.   Choose your launch configuration and under ‘Debugger’ tab, set ‘Stop on start at’ option as ‘Program entry point’. 

entry point.png

 

Then start downloading program again, the debugger will hate at the entry point. You can step into the program to find out the problem.  For how to find out the root cause, you may refer to:

https://mcuoneclipse.com/2012/11/24/debugging-hard-faults-on-arm-cortex-m/

https://mcuoneclipse.com/2012/12/28/a-processor-expert-component-to-help-with-hard-faults/

https://mcuoneclipse.com/2015/07/05/debugging-arm-cortex-m-hard-faults-with-gdb-custom-command/

Best Regards
Fiona Kuang
TIC - Technical Information Center
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Mark Correct button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
866 Views
armendgecaj
Contributor III

Hello Kuang,

thank you. I will try it.

But perhaps i have already found the problem. I think my global variable is to big (Labyrinth[240][320]).

If i decrease my global variable then i get no hard_fault.

I explained it in my answer to Alice. 

Now the question is, is it possible to work with such big global variables?

Best Regards

Armend

0 Kudos
866 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Armend,

There are a lot of possibilities the project run to " hard_fault",

for examplenot enable the clock of one peripheral , while directly use it ;

or the wrong interrupt vector; or select the wrong chip when download ;

Or the wrong parameter when call one function , and so on.

I recommend you debug step one by one ,check when run which code , it run to hard_fault.

Or you can also send your project to me , i help you debug on my side .

Hope it helps


Have a great day,
Alice

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
866 Views
armendgecaj
Contributor III

Hi Alice,

thank you for your help.

You you recommend me to run my project step by step and to look at which command it runs to a hard_fault.

Thats a good idea, but it does not work for me because i do not come till running my project. I get a hard_fault before i can run my project.

But i had another idea. I uncomment all my commands in my function. Then i canceled it again for single commands and debugged my project at every step.

I found the following:

My global variable is called: int Labyrinth[240][320]

In my function i fill my global variable. But if i do that i get a hard_fault

As an example, see the following:

int Labyrinth[240][320];

void fill (void)

{

   int i, j;

   for(i = 0; i < 240; i++)

      for(j = 0; j < 320; j++)

         Labyrinth[ i ][ j ] = 1;         //At this command i will get a hard_fault (If i comment this command out then i get no hard_fault)

}

Now if i decrease my global variable to (for example) "int Labyrinth[100][100]", then i get no hard_fault.

So i think my global variable is to big.

I thought if i enlarge my 'm_data' then it should not be a problem. 

But maybe only enlarging 'm_data' do not help very much.

If i do not enlarge 'm_data' then i get a overflowed-error (because of Labyrinth[240][320]).

If i enlarge 'm_data' then i get no overflowed-error but a hard_fault.

Have you any idea how i can work with such big global variables?

Becaues i need Labyrinth[240][320] to show a randomly generated maze on my LCD-Dispaly (my DIsplay have 240x320 pixel).

Best Regards

Armend

0 Kudos