Content originally posted in LPCWare by frame on Mon Apr 22 03:29:22 MST 2013
A hardfault after a hour or more really points to some "not so obvious" cause.
Lacking further knowledge of your application, I assume it is triggered by an
asynchronuous event, most probably in the course of an interrupt.
One possibility is a stack overflow. You might run on the limit of stack usage.
If probability hits and two rare interrupts nest, you have a stack overflow with
erratic behavior, most probably ending in a hardfault.
Backtracking this kind of error using the stackframe could prove unrewarding,
because of the asynchronuous nature of causing events.
The issue might go away with increased stacksize, but this would be a hint, and not
a prove of the cause.
Another possibility is an actual implementation error, which manifests only on certain
conditions.This might be triggered by some values/data received during an interrupt.
To state an example - I had an application that accessed a lookup table from within
an interrupt routine. This application crashed after a few minutes.
As it turned out, I exceeded the array bound under certain occasions.
To investigate this problem, you could include debug output in your application,
and log it. You might need more several runs to narrow down on the cause.
Wether you use semihosting or UART/USB output depends on your application
and available tools.