So I was playing around with interrupts. Uploading was working without problem, and everything was fine. Until I uploaded the sketch below. It also worked, blinked the LED at pin 13 twice a second. I thought I’d change that, and tried to upload something new, but then the programmer could no longer upload. It fails with the dreaded error “avrdude: ser_recv(): programmer is not responding, avrdude: stk500_recv(): programmer is not responding”.
I’ve tried resetting, tried unplugging and re-plugging, holding the reset-button till right before the programmer kicks in. I’ve tried different baud rates. I’ve tried removing the avrdude -D switch (Disable auto erase for flash). No luck. I can no longer program the chip, while the light is blinking away happily. Oh, and the usual tx/rx blinks when programming never occurs.
It seems the code below is overloading the chip? Any other ideas before I have to start looking into programming it off a bread board?
Here’s the sketch of death. (Underscores deliberately added, so nobody will run this without effort).
*** PLEASE DO NOT RUN THIS LIKE I DID! ***
static volatile uint8_t state = 0;
void __setup__() {
pinMode(13, OUTPUT);
uint16_t speed = 2;
uint16_t ocr1a = (F_CPU / 8UL) / speed;
TCCR1A = 0;
TCCR1B = _BV(WGM12) | _BV(CS10);
OCR1A = ocr1a;
TIMSK1 |= _BV(OCIE1A);
}
ISR__(TIMER1_COMPA_vect) {
state = ~state;
}
void loop__() {
digitalWrite(13, state);
}