简体   繁体   中英

Trouble returning from functions STM32F051C6 (Hard fault)

So I've bee stuck with this problem for a while. Towards the end of my code whenever I call a function it can no longer return to the main function and causes a hard-fault error. I checked that it does reach the end of the function using breakpoints.

If I copy the code from the function into the main function it works with no problem, but makes the code less readable and repetitive.

Any idea why this happens and a way to fix it.

I am using the STM32F051C6 and programming in c in Eclipse.

This sounds like your stack overflows. Usually the stack size is defined in your linker file, try increasing it.

Check for recursive function calls which would fill your stack easily.

This could also be a memory issue like unknowingly overwriting your stack. Check for array and pointer accesses inside your function that cannot return.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM