Dear all,
While testing timer1 input capture on an Arduino Micro, I get this strange behaviour:
As soon as I try to upload the following sketch, the arduino loose connection with the PC. And it is no more possible to reconnect. The card is not detected and I have a Device Descriptor Failure on the USB device manager. Basic scripts from the example folder were working fine (I tested blink led).
Is there something wrong with the code that prevent the serial com to work properly with the PC ? Or is the bootloader corrupted by my setup ?
Setup :
Arduino IDE 1.8.1 (freshly reinstalled on the computer)
Surface Pro 3 (so with USB)
Arduino Micro
The code :
// Test Input Capture
const int ledPin = LED_BUILTIN;// the number of the LED pin
volatile bool event;
void setup() {
pinMode(ledPin, OUTPUT);
TCCR1B |= 0<<ICNC1;
TCCR1B |= 1<<ICES1;
TCCR1B |= 1<<CS10;
TIMSK1 = (1<<ICIE1) | (1<<TOIE1);
pinMode(4, INPUT);
event = false;
}
ISR(TIMER1_CAPT_vect) {
if(event)
event = false;
else
event = true;
}
void loop() {
if(event) digitalWrite(ledPin, HIGH);
else digitalWrite(ledPin, LOW);
delay(100);
}
I tested the arduino with an old PC with USB2, same IDE, it seems that the computer managed to detect the card but it's still impossible to get the script loaded as the compiler dont find the device.
does anyone get the same kind of problems ? I would appreciate any help on the matter.
especially, if my setup is corrupted, what should be fixed, which driver ? I have already uninstalled and reinstalled the latest IDE version and same things happen.
Thanks,
Best