Hi there,
I'm having a strange debug issue which I do not understand.
Details:
Arduino Sketch for Arduino Leonardo
--> get's compiled, but let the arduino hang. Code in setup() seems not to run
The sketch is doing almost nothing (commented out almost everything to track down the issue), but:
* initialize a static object of one of my libraries
* setup() runs a "blink test" with the onboard LED
My expectation was, that when I run this in Atmel Studio (on Win10 in Virtualbox with ATMEL ICE debugger) and debug the code, that I find some kind of uninitialized variables or so, which crash the AVR.
But I face this:
https://www.youtube.com/watch?v=...
I'm not so familiar with the internals of the Arduino code, but it seems that there's a problem with the timer. "micros()" always returns the same time (0x000008ae).
The delay() is called from this function in CDC.cpp:
// This operator is a convenient way for a sketch to check whether the // port has actually been configured and opened by the host (as opposed // to just being connected to the host). It can be used, for example, in // setup() before printing to ensure that an application on the host is // actually ready to receive and display the data. // We add a short delay before returning to fix a bug observed by Federico // where the port is configured (lineState != 0) but not quite opened. Serial_::operator bool() { bool result = false; if (_usbLineInfo.lineState > 0) result = true; delay(10); return result; }
The strange thing is:
- I don't get any hint (stacktrace...) on which line of code is calling this function
- I'm sure that neither setup()/loop() nor the constructor of the static class instance is using Serial (as I said, commented out almost everything to keep it simple)
If I fake the "m" variable in the delay() function during debug, so that the delay finally returns, sketch continues and code in setup() finally runs.
I'm finally not sure if I really debug the issue I face with the arduino IDE (arduino.cc), or if this is a new side-effect from importing the sketch to Atmel Studio :-(
Has anybody any clue on what's wrong with this?