I've wanted to use 250kHz for an application(on an Arduino UNO). Later I added some code which counts (from 0) to 65535(0xffff) on every half of clock cycle, and toggles digital pin 13 when overflows. When I've made some changes and wanted to upload, it has compiled, started uploading and my program has started running( digital pin 13 started blinking). There've been messages about the programmer being not in sync. Here is the last code I successfully uploaded:
void setup() {
pinMode(13,OUTPUT);
pinMode(6,OUTPUT);
TCCR0A=0x42;
TCCR0B=0X82;
OCR0A=3;
OCR0B=0;
TIMSK0=2;
TIFR0=2;
}
int counter=0;
bool pin=false;
ISR(TIMER0_COMPA_vect){
if(counter==0xffff){
counter=0;
pin=!pin;
digitalWrite(13,pin?HIGH:LOW);
}
counter++;
}
void loop() {
//
}
I've visited the Arduino Help Center page, navigated to the particular problem. I did a loopback test and the board failed. Next I tried updating the firmware as shown on this page. Tip: if you're using Windows, you need the 32-bit JRE. I've not managed to switch it into DFU mode. I looked at the forum page, but I hadn't managed to fix it still. It seems that the solution is to either replace the board or to further attempt programming the ATmega16u2 using its corresponding ICSP pins.