Skip to content

Instantly share code, notes, and snippets.

@prrraveen
Created July 23, 2018 11:31
Show Gist options
  • Save prrraveen/2613bbe3477da9fc5b1bf2143c25fadc to your computer and use it in GitHub Desktop.
Save prrraveen/2613bbe3477da9fc5b1bf2143c25fadc to your computer and use it in GitHub Desktop.
jump to bootloader from main app
#include <avr/io.h>
#include <util/delay.h>
#include <avr/wdt.h>
typedef void (*do_reboot_t)(void);
const do_reboot_t do_reboot = (do_reboot_t)((FLASHEND-1023)>>1);
int main (void)
{
DDRB = 0xFF;
for (int i=0; i < 15; i++) {
// toggle PORTB pins
PORTB ^= 0xFF;
// wait one second
_delay_ms(300);
}
//MCUSR=0;
do_reboot();
//MCUSR = 0;
//wdt_reset();
//wdt_enable(WDTO_1S);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment