2025-04-18 5:03 AM
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.
Solved! Go to Solution.
2025-04-18 6:56 AM
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.
2025-04-18 5:15 AM
show code
2025-04-18 6:56 AM
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.
2025-04-18 8:01 AM
@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:
2025-04-18 8:13 AM - edited 2025-04-18 9:24 AM
I found the fault. Increased the size of array and not crashing anymore.
2025-04-18 9:17 AM
@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.
2025-04-18 9:23 AM
Hi andrew,
The array length was insufficient...