Mega2560 USB interface enable/disable

Hello all:

I've proto'd an application which bases off the Mega2560 R3 board. I have a need to be able to enable/disable the USB interface for the next version of my prototype. When the application is operating normally, the USB interface is to be disabled. When the user wants to either upload new software or display debug info, the user activates a switch input to enable USB first. I would appreciate options from the experienced crowd here on the best way forward. I have already tried using the switch input to hold the 16U2 chip in reset and release the reset line when USB connectivity is needed. While this meets my objective, it forces the user to power cycle the prototype after the switch input is placed back to its "normal" position. This is an unacceptable burden I do not want to place on the user. In essence, I want to isolate the microcontroller from the outside world when USB connectivity is not needed (a security feature).

  1. Is simply switching off +5V to the USB chip the answer ? I'm worried about a depowered chip receiving a voltage input from a USB connection, potentially causing damage.

  2. I've looked at FT230X, as it is a bit cheaper, but cannot see a method of hardware disabling.

I'd appreciate your opinion on other possible solutions.
Much thanks,
shockah

You can remove the DTR-to-Reset line perhaps.
http://arduino.cc/en/Main/arduinoBoardMega2560
"The Mega2560 contains a trace that can be cut to disable the auto-reset ... You may also be able to disable the auto-reset by connecting a 110 ohm resistor from 5V to the reset line ..."

Or do something in the bootloader of the ATmega2560 or in the firmware of the usb-serial ATmega16U2.
For example a bootloader in the Mega2560 that checks a normal digital pin. I don't know if the Optiboot for the Mega2560 requires a new board definition in 'boards.txt'. I think it does.

How is the board powered, with the usb connector or with the DC barrel jack ?

The Mega2560 is powered through the barrel jack. Deriving power through USB is not needed, despite being supported by the Mega2560. In fact, in my next prototype build, I plan to remove the +5V connection from the USB connector to the USB interface chip (whatever that turns out to be).

Modifying the bootloader I think is beyond me. I thought about modifying the 16U2 software to add a digital input (fed from my USB enabling switch input). I think I could get that to work. My preference though is for a solution not requiring more code to manage (in a second chip). And of course is cheaper, like a FT230X.

I have a need to be able to enable/disable the USB interface

Why ?
About the only effect of having the USB chip enabled is a permanent pullup on the D0 (rx0, PE0) pin...

westfw:
Why ?

Always that nagging question here!

why, fair question. This is a security feature.

I cannot see why the 16U2 would fail to initialise after releasing the Reset.

If the main MCU UART has locked up on an apparent "break" while the USB was disabled, then you need a pull-up - 10k or so - on the serial line to prevent this.

I've just ordered an FT230X eval board. FTDI tech support says disabling is feasible. And I get a cheaper design without the hassle of more custom software to deal with (using the 16U2).

thanks to all who chimed in on this thread.
shockah