On ATmega32U4, Can the 2 Legs for the Serial Port Be Used for Other Purposes?

Hi

On the ATmega32U4, Legs D0 and D1 are used for (hardware) Serial Port #1 (which in code, is called Serial1).

Can I use these 2 legs not as a Serial Port, but as 2 Input legs for example?

I assume that because those 2 legs are named D0 and D1, then the answer is yes,
but it's important for me to verify this.

Also, If I may ask the same question about the ATmega328..
The only Serial Port there (which in code is named Serial),
can the 2 legs there D0 and D1 be used for Input?

Thank you

Why do you not write a small sketch to test it? that is the more simple way to clear such questions!
If you deal with digitalInput(...) there is no danger!

card5:
I assume that because those 2 legs are named D0 and D1, then the answer is yes,
but it's important for me to verify this.

The answer to your question is YES (assuming you don't need to use Serial1).

However I'm interested to know what you are worried might happen if you could not verify this.?

...R

Thank you Robin2

Robin2:
However I'm interested to know what you are worried might happen if you could not verify this.?

I will gladly tell you.

I have a nice Microcontroller board called Cactus Micro rev2:

http://www.seeedstudio.com/depot/Cactus-Micro-Rev2-Arduino-compatible-plus-esp8266-p-2544.html

In short, it is an ATmega32U4+ESP8266.

The ATmega32U4's Serial is conncted to USB,
and the ATmega32U4's Serial1 is conncted to the ESP8266's Serial Port.

So far so good.
Lately I wanted to flash the Firmware of the ESP8266,
but since its 2 Serial Legs are not exposed as the Cactus Micro's legs, then users have to flash the ESP8266 via the ATmega32U4, using a small sketch that simply relays data between the ATmega32U4 and the ESP8266.

It should work, yet it doesn't and I wasted on it quite some time..
So I thought to myself that it would be simpler to directly connect to the ESP8266, and flash it like that.

The problem:
As written above, the ESP8266's Serial Port is already connected to something - that is the ATmega32U4's Serial Port (ATmega32U4 Legs D0 and D1).
So If I connect with an FTDI adapter directly to ESP8266's serial legs, I am also connecting to ATmega32U4's serial legs..
And that can make a short circuit, because when I connect FTDI.TX to ESP8266.RX,
I am also connecting FTDI.TX to ATmega32U4.TX.

So I have 2 options:

  1. Disconnect this connection between the ATmega32U4 and the ESP8266
    (impractical, unless I want to ruin the PCB)
    or:
  2. Leave that connection intact, yet not have any problem occurring due to it.

Option #2 can be achieved via making the ATmega32U4's Serial Port (Serial1) legs behave as input,
and having the ATmega32U4 ignore the data.
By being Input legs, no short circuit should happen,
and I can communicate freely with the ESP8266's serial port..

card5:
In short, it is an ATmega32U4+ESP8266.

You should have told us that in your Original Post.

I have no experience of that board. All my comments related to a stand-alone Arduino board with a 32u4 such as a Leonardo or Micro.

You should ask seedstudio about what you want to do.

...R

Well,
An ATmega32U4 is an ATmega32U4, no matter which board it is on, no?

And I checked the schematic of that board,
the Serial Port legs are connected as I wrote above, no other surprised there.
So the only problem left is making the ATmega32U4 not use them as Serial Port, mainly because the problem is with the TX leg, not the RX leg of the ATmega32U4.

card5:
And I checked the schematic of that board,
the Serial Port legs are connected as I wrote above,

Then you know a lot more about it than I do - hence my caution.

...R