Hard fault – Sometimes

I have an extremely difficult to catch hard fault. I suspect it happens somewhere during initialization, as if the system starts running it will run for days with no issues. However, once in a while, a hard fault happens after reset. I set a break point at the hard fault interrupt, and I can see that the call stack is empty, only shows “void f() “, Can the FreeRTOS+ Trace be used to find out what is going on? My ARM assembly knowledge is very low. Thanks for any help… Johanan

Hard fault – Sometimes

I suspect it happens somewhere during initialization
FreeRTOS will leave interrupts disabled as soon as you start to call FreeRTOS API functions. That is done to ensure interrupts do not execute until after the scheduler has started, in case an interrupt service routine attempts to use the FreeRTOS API, and the API function called attempts a context switch (which would not make sense before any tasks were running). If you are hitting a hard fault before the scheduler is started, could it be that something you are doing during initialisation is enabling interrupts? Can you put a break point in your ISRs, or simply set a variable that can be inspected from the hard fault handler to see if any ISRs have executed, to see if this is the case? Regards.

Hard fault – Sometimes

I will set a counting variable on each interrupt entry, and will check. Thanks.

Hard fault – Sometimes

Can’t believe did this, but I forgot to call one xEventGroupCreate() … I wonder how it worked at all sometimes. Johanan