Arduino destroyed after uploading wrong code?

Hello

I did some experiments with timer0 in CTC mode and interrupts. However, as soon as I uploaded the code, my Arduino Micro seems broken. Everything went just fine before. As soon as I try to plug the USB in a PC (with Windows 10), I get an error message. I get the same message even on a completely other computer.

Windows has stopped this device because it has reported problems. (Code 43)

A request for the USB device descriptor failed.

That lets me exclude the idea that something with the computer settings is wrong. My Arduino worked just fine on both of the computers before.

void timer0_init()
{
	TCNT0 = 0; // Initialize counter
	TCCR0A = (1 << WGM01); // Enable CTC mode (Clear Time on Compare)
	TCCR0B = (1 << CS00); // Clock timer at 16MHz
	OCR0A = 159; // Set the max compare value so we achieve 100kHz (16000000 / 100000 - 1)
	TIMSK0 |= (1 << OCIE0A); // Enable timer compare interrupt
}

// Called by timer0 evey 100khz
ISR(TIMER0_COMPA_vect)
{ 
	if (buffer_index >= BUFFER_SIZE)
	{
		buffer_index = 0;
		buffer_full = true;
	}
	else if (buffer_full == false)
	{
		buf[buffer_index++] = (double)fast_adc_read(2);
	}
}

My Idea ist, that the timer0 runs too fast and therefore every other operation is blocked. Hope you can help me.

Yikes. I think you are right that 100,000 interrupts per second is interfering with the USB interface. Try uploading a simple sketch like Blink. Repeat that while pressing the Reset button at various times in the process.

If all else fails you could install a fresh bootloader.

(deleted)

Thank you guys very much! The idea of pressing the reset button several times while uploading the blink program fixed it! Maybe I entered the boot loader mode that way unknowingly.

eggersa:
Thank you guys very much! The idea of pressing the reset button several times while uploading the blink program fixed it! Maybe I entered the boot loader mode that way unknowingly.

Well, you should have done it knowingly, that's exactly what you do to get it into the bootloader when your sketch hoses the USB.