Thanks guys for your answers. I'd like to test the watchdog solution though. Not sure about my bootloader.
I found that:
CAUTION! On newer AVRs, once the watchdog is enabled, then it stays enabled, even after a reset! For these newer AVRs a function needs to be added to the .init3 section (i.e. during the startup code, before main()) to disable the watchdog early enough so it does not continually reset the AVR.
Here is some example code that creates a macro that can be called to perform a soft reset:
#include <avr/wdt.h>
#define soft_reset()
do
{
wdt_enable(WDTO_15MS);
for(;
{
}
} while(0)
...
// Function Pototype
void wdt_init(void) attribute((naked)) attribute((section(".init3")));
...
// Function Implementation
void wdt_init(void)
{
MCUSR = 0;
wdt_disable();
return;
}
I guess that should work for my Arduino 328?
Franck