Skip to main content
Hjain.1
Associate II
July 3, 2024
Question

Getting Hardfault when creating a local variable and not getting Hardfault when making the same variable Global

Hi,

Im using threadx, in that i have defined a task in which i initialize my external flash memory regions 
i have a 116 byte structure which contains memory information

when i use this structure locally i get a never execute hardfault error where as when i move that variable to global i dont get hardfault
please note that the stack size of task is 6200 bytes
Attaching screenshots

This topic has been closed for replies.

3 replies

Andrew Neil
Super User
July 3, 2024

@Hjain.1 wrote:

please note that the stack size of task is 6200 bytes


So have you tried increasing that - by at least 116 bytes ... ?

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.
Hjain.1
Hjain.1Author
Associate II
July 3, 2024

as you can see my stack is barely full only 2kb is used and yes i did try increasing it

Tesla DeLorean
Guru
July 3, 2024

What specifically is the nature of the Hard Fault, see registers, stack and instructions. 

If not a stack overflow, perhaps corruption or modifying out of bounds.

Failure at return?

Use for a DMA or IT routine and losing scope?

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..