diff options
Diffstat (limited to 'BootloaderCDC.c')
-rw-r--r-- | BootloaderCDC.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/BootloaderCDC.c b/BootloaderCDC.c index 3ea56fc..fbc777f 100644 --- a/BootloaderCDC.c +++ b/BootloaderCDC.c @@ -77,6 +77,11 @@ int main(void) sei(); /* Timer init */ + TCCR0B_backup = TCCR0B; + TCCR0A_backup = TCCR0A; + TIMSK0_backup = TIMSK0; + TIFR0_backup = TIFR0; + TCCR0B = 1 << CS02 | 1 << CS00; // prescaler = / 1024, i.e. 15625 Hz TCCR0A = 0; // 8-bit normal mode TIMSK0 = 1 << TOIE0; // Enable Timer0 @@ -97,7 +102,16 @@ int main(void) /* Jump to main program. */ cli(); - TIMSK0 = 0 << TOIE0; // Disable Timer0 interrupt + + // Restore system state + TCCR0B = TCCR0B_backup; + TCCR0A = TCCR0A_backup; + TIMSK0 = TIMSK0_backup; + TIFR0 = TIFR0_backup; + + MCUCR = (1 << IVCE); + MCUCR = (0 << IVSEL); + __asm("jmp 0x0000"); for (;;); |