2013-10-14 10:48 AM
Hi ALL ,
I have a question that is bugging me lately and i could not find any good solution for the problem. Suppose I have a function , that may or may not , depend on the input and the amount of fixed bugs ;) , to got stuck somewhere inside in an infinite loop . Is there any way for the cortex to recover from this infinite loop , without doing a hardware reset ? Thanks Michael2013-10-14 11:01 AM
Watchdog Interrupt?
2013-10-14 12:32 PM
Any function that may get stuck in an infinite loop should be coded with some kind of timeout or maximum number of re-try.
Better yet, do not baby sit the hardware with CPU expensive loops and polling hardware status bits.Use the hardware to it's full advantage, by using interrupts and DMA.Use I/O pins to driver external devices power (via a FET or some such) so that if a part stops responding, power cycle it. (it may latch up from ESD events)Use state machine drivers, if a device gets stuck in some state, then re-init it or power cycle it.Non of the firmware that any vendor supplies is production worthy! They provide examples of perfectly working code, for perfectly working hardware in a perfect world, which you an I know, it does not exist.Read up on ''correct'' vs ''robust'' code. I also learned a lot from Safety Critical Design Patterns2013-10-15 05:56 AM
re watchdog interrupt.
the WD is NOT a fix, it is NOT a method, it is NOT a remedy. If a device of my design creates a watchdo interrupt, it is recorded with all details and the unit report ''maintenance required'' do you want to have to use your fire extinguisher?2013-10-15 06:33 AM
It does however represent the closest thing to a ''stupid code running'' detector.
The processor runs code blindly, it makes no cognitive decisions about whether a code sequence is sensible or not, that's the job of the coder.2013-10-15 07:11 AM
the WD is NOT a fix, it is NOT a method, it is NOT a remedy.
It should of course not be used as such, but it is a proved method to deal with transient EMI problems. Sometimes, system integrity may get lost without SW designers's fault ...