Ever find yourself wasting SECONDS of your life waiting for the arduino to 'reset' after you upload a new sketch
and then you also have to wait SECONDS for the app to start?
NO MORE!
this quick hack will automatically reset the arduino after uploading and skip the bootloader. To get back into the bootloader, just press the reset button (or use the diecimila 'auto-reset' capability). This hack uses the watchdog timer and MCU status register to figure out how the chip was reset
in main(), change the begining of the code to:
/* main program starts here */
int main(void)
{
uint8_t ch,ch2;
uint16_t w;
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(WDRF)) // if its a watchdog reset...
app_start(); // skip bootloader
/* set pin direction for bootloader pin and enable pullup */
/* for ATmega128, two pins need to be initialized */
then change the 'Q' command later on...
/* Leave programming mode */
else if(ch=='Q') {
nothing_response();
// autoreset via watchdog (sneaky!)
WDTCSR = _BV(WDE);
while (1); // 16 ms
}