cancel
Showing results for 
Search instead for 
Did you mean: 

Going in HardFault

Nico3
Senior

I plan to transmit stream of approx 10k characters by uart every second. For that purpose, I have definer global char array of 10.5k length. After working for few second, the MCU goes in HardFault.

I tried with array of 1000 bytes only, it works fine. But as I increased to 10k bytes array, problem start coming.

Should I change stack sizes in linker file. ? please suggest and where to change. 

 

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

Global arrays don't use the stack.

Possibly a write out of bounds causing issues. Definitely a bug in the code somewhere. I suggesting finding and fixing the bug.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

6 REPLIES 6
MM..1
Chief III

show code 

TDK
Guru

Global arrays don't use the stack.

Possibly a write out of bounds causing issues. Definitely a bug in the code somewhere. I suggesting finding and fixing the bug.

If you feel a post has answered your question, please click "Accept as Solution".

@Nico3 wrote:

I plan to transmit stream of approx 10k characters by uart every second.


So, with 10 bits/character, about 100kbit/s.

Certainly, the UART hardware can cope with that.

But can your code keep up?

 


@Nico3 wrote:

I tried with array of 1000 bytes only, it works fine. But as I increased to 10k bytes array, problem start coming.


So narrow it down some more - try sizes between 1k and 10k

 


@Nico3 wrote:

the MCU goes in HardFault.


So you need to find what's causing the Hard Fault:

https://community.st.com/t5/community-guidelines/how-to-write-your-question-to-maximize-your-chances-to-find-a/tac-p/708193/highlight/true#M51

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.
Nico3
Senior

I found the fault. Increased the size of array and not crashing anymore. 

 


@Nico3 wrote:

I found the fault.


Good to hear - so what, exactly, was the problem?

please mark that post as the solution.

See: https://community.st.com/t5/community-guidelines/help-others-to-solve-their-issues/ta-p/575256

 


@Nico3 wrote:

But i see another problem now. .


Please start a new thread for that.

 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

Hi andrew,  

The array length was insufficient...