Hello,
I currently am working on a small project and I need to reset the whole arduino into bootloader programming mode. I have a pro mini, atmega328
The way I currently tried is: asm volatile (" jmp 30720");
This does send it into the bootloader, but it won't respond to any serial commands. Normally when it boots, I can send a '1 ' command to get 'AVR ISP'
The other way I can think of is using a watchdog timer. I would prefer not to use a watchdog.
I am doing this without a standard FDTI cable, so upon connecting there are a few extra characters sent to the arduino before the connection is established.
I've changed the bootloader to have a longer wait time(yes, I did it in the makefile) and to have a higher max error.
The original bootloader has problems with the watchdog. The Pro Mini uses the original bootloader...
pro5v328.bootloader.file=ATmegaBOOT_168_atmega328.hex
#ifdef WATCHDOG_MODS
ch = MCUSR;
MCUSR = 0;
WDTCSR |= _BV(WDCE) | _BV(WDE);
WDTCSR = 0;
// Check if the WDT was used to reset, in which case we dont bootload and skip straight to the code. woot.
if (! (ch & _BV(EXTRF))) // if its a not an external reset...
app_start(); // skip bootloader
#else
asm volatile("nop\n\t");
#endif
Almost. You will need to comment-out (or remove) this part...
// Check if the WDT was used to reset, in which case we dont bootload and skip straight to the code. woot.
if (! (ch & _BV(EXTRF))) // if its a not an external reset...
app_start(); // skip bootloader
That bit of code skips the bootloader and jumps straight to the application in the event of a watchdog reset. In your case, you want the bootloader to run.
Exactly. The jump you tried only "restarts" the software. It does not reset the processor. Interrupts will be enabled and able to fire. Any pins set to outputs will remain outputs. Any PWM running will continue to run. The hardware is left exactly as it was when the jump was executed.