So here is an interesting problem. I have an application using and XMEGA series chip and I need to be able to do a reset in the event of failure. Normally a perfect case for the WDT, right? Well there is a hiccup in my case: the real time counter. I need it to keep running at all times, and I need to retain the value across resets. There are also a few other values that I would like to save. To complicate matters further, I am using a boot loader, which the reset vector points to, so "jmp 0000" doesn't work (at least not for debugging since the boot loader isn't present yet). Long story short, I need to do a very soft reset.
The solution I came up with was to use a timer on the highest interrupt level (the XMEGA series has 3 levels) that would clear out several likely error sources (TWI, ADC, etc.), reset a few specific variables, shut down attached hardware, then jump. Basically a soft WDT, including a reset function that clears the timers counter.
With all of that out of the way, here's my actual question. The solution I came up with for the jump was to create a function pointer to main and jump to that. That way it would re-init my hardware without losing everything then re-start my state machine loop. What are the pitfalls of this? What problems could be caused by jumping just to main()? I still have the actual WDT on it's longest period in case of catastrophic failure, and I write the RTC values to the eeprom just in case, but this seemed like an easy solution for my soft reset. Am I wrong?