Does the MCU you're using support a watchdog timer?The very last thing I'll probably do, after *all* the code is finished, is to add a supervisor that performs a hard hardware reset in the case of timeout errors. I haven't had any, but if I did, the current code would try to limp on, probably unsuccessfully.