Power Supply and USB Cable

Hi,

I'm supplying arduino with external power supply(12v) and at the same time, i'm trying to upload my code to mega but my usb bus are closing itself and i can't upload code. How can i block this thing to not happen?

How can i block this thing to not happen?

It is not supposed to happen. There is a circuit in the Arduino that automatically switches to the correct power supply. It sounds like this circuit is not working.

I've seen some 3.3v. arduinos advertised. I assume that if you hook a 5v. USB to a 3.3v. Arduino, the voltage mismatch could be a problem. But that's probably not what you're using.

I recently had a problem with a Moteino Mega, which is not an Arduino mega, but is programmable using the Arduino IDE. It is a 3.3v device, and it will be talking to an exclusively 3.3 v. display. So I had a 3.3 v. power rail on my breadboard feeding the Mega. But when I hooked up the external USB, the 3.3 v. rail jumped to
5 v.! If I had had the display hooked up at that moment, it would have possibly been bye-bye display. I solved the problem by modifying my FTDI cable so that it did not pass the 5 v. to the Mega. Fortunately, the voltage discrepancy between the Mega and the computer USB didn't affect the serial communications.

With this mixing of 5v. and 3.3 v. parts, it's going be very tricky to keep the voltages where they belong. ANd when the smoke leaves the chip, it's over.

Ancotar:
Hi,

I'm supplying arduino with external power supply(12v) and at the same time, i'm trying to upload my code to mega but my usb bus are closing itself and i can't upload code. How can i block this thing to not happen?

Usually that's because you've over-currented the USB interface and it shuts down - have you checked for
a short on your 5V rail?

Perhaps your 12V is getting where it shouldn't? That's bad news - you could damage the computer,
not just the Arduino - it might be worth investing in a powered USB hub to separate computer power
from USB on the Arduino.