I have been actively developing some USB applications with the Leonardo board and seem to have found an issue with the hardware design. Please note that I am using the LUFA library rather than the Arduino IDE, however the problem will effect both environments.
Under testing the Leonardo was showing odd behaviour when the USB cable was disconnected and reconnected (whilst the board was externally powered by a 9V PSU). The disconnect event (and therefore the reconnect event) was being missed by the LUFA library monitoring the VUSB pin.
By soldering a wire to the VUSB pin (7) of the ATmega32U4 I got the attached trace from my DSO. As the trace shows, the VUSB pin is taking over 10 seconds to drop from 5Vs to 0Vs once the USB cable was unplugged. This not only caused a 5 second delay before the VUSB was seen as logic 0 by the chip, but also caused 3 connect ‘bounces’ as the pin hovered around the logic 1 to 0 threshold.
Examining the circuit more closely - the issue seems to be caused by the combination of C8 (a 10uF capacitor recommended by the Atmel datasheet) and T1 - a P-channel MOSFET which isolates VUSB when the board is on external power. Since there is no power draw on VUSB the power drains slowly though C8 causing the long delay.
The solution is to pull-down VUSB to Gnd using a 10Kohm (or so) resistor, however this requires soldering to the board since pin 7 isn’t exposed by the Arduino headers.
Although this isn’t disastrous it will effect the outcome of projects especially once the Arduino’s IDE USB capabilities become more powerful. Obviously those planning on using LUFA with the Leonardo should be aware of this if building a self-powered device.
Unless I am somehow in error here, perhaps an Errata for the board might be a good idea?