3
\$\begingroup\$

The Arduino Uno has one main controller and one controller serving as USB-to-serial interface. The RX/TX pins of the main controller are directly connected, via 1k resistors, to some pins of the "communication controller". RX/TX pins are also on one of the pin headers.

I'm wondering whether the TX pin of the "communication controller" (connected to the RX pin of the main controller) goes into high state (or is switched to input state) when no USB cable is connected and whether I could use the RX/TX pins on the header to connect some other stuff on a homegrown shield and perform serial communication through this shield.

\$\endgroup\$
6
  • \$\begingroup\$ Many shields use SPI to completely avoid these issues. Why not look in that direction? \$\endgroup\$
    – Mels
    Commented Jul 31, 2013 at 13:30
  • \$\begingroup\$ Unfortunately, I need asynchronous communication, so SPI is no option for - unless I would connect a SPI interfaced UART like the MAX3100, but that seems to be a bit overkill for the moment. \$\endgroup\$
    – wollud1969
    Commented Jul 31, 2013 at 17:14
  • \$\begingroup\$ Ah, ok. If you need the UART on your shield and you don't want to be taking it off all the time, consider including a switch to disconnect the UART pins - otherwise you probably won't be able to do USB programming while the shield is on the Uno. \$\endgroup\$
    – Mels
    Commented Aug 1, 2013 at 9:58
  • \$\begingroup\$ @Mels: you are right. My plan is to completely unplug the shield when I have to program the Uno. \$\endgroup\$
    – wollud1969
    Commented Aug 1, 2013 at 14:04
  • 1
    \$\begingroup\$ I would advise against that, because while debugging you'll want to switch between USB and your shield very often. I know from experience that frequent unplugging and replugging of a shield will likely bend or damage the shield's header pins and/or the Arduino's female counterparts. The Arduino shield concept was never really designed with frequent installation and removal in mind... \$\endgroup\$
    – Mels
    Commented Aug 2, 2013 at 11:34

2 Answers 2

4
\$\begingroup\$

The TX and RX on the Digital 0 and Digital 1 pins are designated for connecting to your own serial devices, whether a USB cable is connected or not. From the official Uno page:

  • Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data. These pins are connected to the corresponding pins of the ATmega8U2 USB-to-TTL Serial chip.

Also:

The RX and TX LEDs on the board will flash when data is being transmitted via the USB-to-serial chip and USB connection to the computer (but not for serial communication on pins 0 and 1)

Of course, you can also use the SoftwareSerial library to communicate with serial TTL devices on any GPIO pins you like, not restricted to D0 and D1.

\$\endgroup\$
7
  • 1
    \$\begingroup\$ Okay, but I haven't found any statement about how the communication controller drives the line. I really want to avoid SoftwareSerial. It might to be a last resort howvever. \$\endgroup\$
    – wollud1969
    Commented Jul 31, 2013 at 17:18
  • \$\begingroup\$ BTW: has anyone a hint for me where on the arduino homepage or in the arduino repo I could find the code for the communication controller? \$\endgroup\$
    – wollud1969
    Commented Jul 31, 2013 at 17:19
  • 1
    \$\begingroup\$ @wollud1969 github.com/arduino/Arduino/blob/master/hardware/arduino/… \$\endgroup\$
    – Passerby
    Commented Jul 31, 2013 at 19:02
  • \$\begingroup\$ Okay, I found the code. Indeed, TXEN is set somewhere in the init phase and never reset. So, indeed, TX is always active. Ugh! Maybe I should ask in an Arduino forum, why it is not reset to disable TX when no USB is connected. However, for now, I need to overwrite the signal behind the resistor with enough current and have to remove my shield when firmware is uploaded to the Arduino main controller. \$\endgroup\$
    – wollud1969
    Commented Aug 1, 2013 at 7:24
  • \$\begingroup\$ @wollud1969 Your code can always reset TXEN. However, the reason USB transmission is left enabled is because USB can be plugged in or disconnected at any time, without resetting the board, so long as power is supplied to the board separately. \$\endgroup\$ Commented Aug 1, 2013 at 12:02
2
\$\begingroup\$

That's the entire point of the 1k series resistors. Anything connected directly to those pins, like say a shield, will take precedence over the serial resistor blocked ATMega8u.

To note, the ATMega8u (or 16u in some versions of the Uno or Mega) has it's serial communication handled by the USART. The TX pin is not manually turned into an output, internal circuitry that automatically handles data transmission drives the pin instead. An active, but idle serial link, will keep the TX pin high.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ So, I would need to drive the TX line with at least 5mA to overwrite the high signal behind the resistor. However, maybe it is required, but also doesn't seems to be the perfect solution. Concerning the output state of the TX pin: the controller could take TXEN down if no USB is connected to put the pin into high state. \$\endgroup\$
    – wollud1969
    Commented Jul 31, 2013 at 17:16
  • \$\begingroup\$ @wollud1969 ttl serial, +v IS the 0/Mark/Low state. Active low. And considering the Baud speed, the length of a low signal, 5mA but for a fraction of a fraction of a second. Not a significant current drain. \$\endgroup\$
    – Passerby
    Commented Jul 31, 2013 at 19:02
  • \$\begingroup\$ Interesting; so the 1k series resistors on the connections to the Atmega8U will impede the current on those lines, versus the zero-resistance connections to the shield (or other UART target). Is that roughly how it works? If so, then why 1K value specifically. Why not, say 100K? \$\endgroup\$
    – boardbite
    Commented Jul 31, 2013 at 21:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.