Skip to content

Instantly share code, notes, and snippets.

@AndryG
Created February 15, 2022 18:42
Show Gist options
  • Save AndryG/0b993daa65279af37162bd21bd898c1f to your computer and use it in GitHub Desktop.
Save AndryG/0b993daa65279af37162bd21bd898c1f to your computer and use it in GitHub Desktop.
avr-gcc self reset
Виявляється, перезавантаження контролера має свої несподівані хитрощі.
void reset(){
wdt_enable(WDTO_15MS);
while(1);
}
// Function to disable wdt after reboot (wdt remains enabled)
void wdt_init(void) __attribute__((naked)) __attribute__((section(".init3")));
void wdt_init(void){
MCUSR = 0; // The datasheet cleared the WDRF bit. Who knows why
wdt_disable();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment