On 2015-02-21 14:09, Nevada Smith wrote:
>
> To understand your Idea bill I simply write what I understood:
> With the (already configured) Arduino protocol avrdude also triggers RTS on reprogramming, so RTS would also work.
> But the difference is that the Serial monitor only triggers DTR so we do not have an autoreset here by default?
Yes. The OS controls the state of DTR and so DTR drops *before* the application runs.
Since the 16u2 code is looking at DTR the output signal from the 16u2 going to AVR reset follows
the state of the CDC DTR level.
The signal level drop is converted to a pulse by the autoreset hardware (the capacitor).
Since RTS is left alone, using RTS instead allows an application to open the serial port and not trigger a reset
unless it really wants it by explicitly dropping/toggling the RTS signal.
So if the 16u2 code simply looked at the RTS signal level instead, the output signal that is driving
the AVR reset would toggle to reset the AVR only when an application explicitly asked for it to be toggled
vs every single time the serial port is opened regardless of whether the reset is actually desired.
>
> I could add this to my bootloader, but I am not sure if it makes sense. People are used to the reset (like me). It might be useful sometimes, but then you could add the USB-Serial Demo of the HID
I think it is a total pain in the ass that a reset occurs every single time the serial port is opened
which is why I switched to using RTS.
When RTS is used you could get the best of all worlds.
Autoreset happens during an upload. No reset happens when the serial port is opened.
And it would be possible to add a button in the Arduino IDE GUI to reset the board should you want
to do that.
With DTR you can't offer the option to talk to a live board without resetting it.
In the case of wanting to run debug wire, the code in the 16u2 code could be changed to assert the AVR reset
when RTS is asserted low but then change the 16u2 "reset" pin back to an input when the RTS is high.
--- bill