Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 10 of 10

Thread: Serial question : Is TX1,RX1 for Serial1 or just Serial? (Ntxt)

  1. #1
    Senior Member jim lee's Avatar
    Join Date
    Dec 2016
    Location
    Anacortes, WA
    Posts
    168

    Serial question : Is TX1,RX1 for Serial1 or just Serial? (Ntxt)

    Or is Serial the same as Serial1 ? I tend to doubt that though..

    Thanks!

    -jim lee

  2. #2
    Senior Member
    Join Date
    Dec 2016
    Location
    Montreal, Canada
    Posts
    3,526
    Serial1 is UART, Serial is SerialUSB

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,462
    They're separate and completely independent of each other.

  4. #4
    Senior Member jim lee's Avatar
    Join Date
    Dec 2016
    Location
    Anacortes, WA
    Posts
    168
    Thanks! I've never had this spelled out to me before and its always been kinda' a mystery/blind spot.

    -jim lee

  5. #5
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,930
    Quote Originally Posted by jim lee View Post
    Thanks! I've never had this spelled out to me before and its always been kinda' a mystery/blind spot.

    -jim lee
    On some boards, particularly the Arduino Uno boards using the AVR 328p, the chip does not have any USB support. So it relies on a second chip on the PCB to manage the USB connection. It watches the serial UART line from the main processor and then talks to the USB host. On those boards, Serial and Serial1 are the same thing. If you want to use a real serial port to talk to something like a GPS, you need to disconnect the board from USB.

    On the Teensy boards (both the older Teensy 2.* boards using the AVR 32U4 and the newer Teensy 3.x/4.x/LC systems using ARM boards), the chip itself can handle USB, and Serial and Serial1 are different.

  6. #6
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    8,201
    To follow on to this.

    As MichaelMeissner mentioned the Arduino Uno uses the AVR ATMega328 chip which only has one hardware UART on it and no native USB support. So both the FTDI chip (or later replaced with another AVR chip atmega8u2) and the Serial (pins 0, 1) object both connect up to the same pins on the 328P processor. Which as mentioned if you are using those pins for something like a GPS, you need to disconnect the USB data... But in addition to this, on the UNO the baud rate you specify on the Serial.begin(115200) makes a difference. As it actually configures the Hardware UART to this speed and then the communication chip has to be setup for that same speed. Which is why on those boards, when you are using a Serial monitor that baud rate most match...

    Since these boards only have one UART and often times there is a desire to communicate to multiple Serial devices, there are libraries like SoftwareSerial, which uses software to emulate (bit bang) out Serial communications. which is why you will see a lot of sketches and libraries that are setup to use libraries like these.

    Note: that some of the AVR based Arduinos, like the MEGA uses a different AVR board ATMega1280 or Atmega2560 which do have multiple Hardware Uarts. If my memory is correct there are 4. Again the first one is used both for USB communications as well as connected to pins 0 and 1.

    Sorry if too much information

  7. #7
    Senior Member jim lee's Avatar
    Join Date
    Dec 2016
    Location
    Anacortes, WA
    Posts
    168
    Too much information? Not in the least! I'm grateful for it.

    I asked because, in my project, I'm stuck. And, I ran into a bit of a informational void on all of this. On the Arduino side I get references that are somewhat arm waving and light on detail. Adafruit? So far I'm getting nothing at all. I fear that something is currently not right in their support group.

    SoftwareSerial is actually what started all this. I'm trying to add a third serial connection to my Adafruit FONA feather. There is already a SoftwareSerial port that talks to the SIM chip, and the standard one to the Serial Monitor. I need one to talk to my Teensy 3.2 so it can receive sensor data. For the life of me I can't get the thing to work. The teensy never "sees" anything coming into the port to ask for a data pack.

    At least now I know to listen to Serial1 on the teensy. That's one less variable to worry about. Now I need to get some answers from Adafruit.

    -jim lee

  8. #8
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,930
    For various reasons, SoftwareSerial does not work on Teensy ARM boards, with the exception that if you specify RX/TX for an existing hardware UART, it will use that. But you can't use arbitrary pins like you can do on other chips.

    The Teensy 3.2 has 3 hardware UART lines plus the USB line:
    • Serial1: RX1 is pin 0, TX1 = pin1;
    • Serial2: RX2 is pin 9, TX2 = pin 10;
    • Serial3: RX3 is pin 7, TX3 = pin 8.


    On the Teensy 3.2, there are some alternate pins that you can use instead of the standard pins with the setTX and setRX functions:
    • https://www.pjrc.com/teensy/td_uart.html
    • For Serial1, pin 21 is the alternate RX pin and pin 5 is the alternate TX pin;
    • For Serial2, solder pad 26 underneath the Teensy is the alternate RX pad, and solder pad 31 is the alternate TX pad; (and)
    • For Serial3, there are no alternate pins.


    I haven't done much with Serial on the Teensy, or even going back in time, real Serial connections (when computers had 9 or 25 pin serial ports) in years (or decades even), but some tips:
    • Make sure both sides use the same serial rate (and it is one of the standard rates, like 9600 or 19200);
    • Make sure the data bits and stop bits are the same (generally use the default, but sometimes the default isn't good enough);
    • Make sure both systems share a common ground wire;
    • Make sure the same voltage is used in both systems (3.3v). If 5v and 3.3v are mixed without conversion, it may work on the Teensy 3.2 and 3.5, and it may break the LC, 3.6, 4.0, and 4.1. Or perhaps mixed voltages just may not work (there are ways to change the voltage levels);
    • Try lower speeds if higher speeds don't work;
    • If you are trying to use higher speeds, you may need to use hardware flow control (this can be an advanced topic);
    • Don't use software flow control (using control-S and control-Q in-band to slow down the communication, particularly if you are sending binary data);
    • Keep your wires short (unless you use hardware protocols for long distance runs);
    • Use good wires. If you use breadboards, make sure the parallel rows are error free;
    • Try to reduce electrical noise;
    • If at all possible, add error control to higher levels of the protocol.
    Last edited by MichaelMeissner; 11-30-2020 at 06:17 AM.

  9. #9
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,462
    I've edited the Hardware Serial Ports page.

    https://www.pjrc.com/teensy/td_uart.html

    Previous it said:

    The most common issue with serial ports on Teensy is use of code designed for Arduino Uno with Serial within the code. On Teensy, Serial accesses the USB. For hardware serial ports, Serial1, Serial2, Serial3, Serial4, Serial5, Serial6, Serial7 or Serial8 must be used.
    I've added these words.

    The most common issue with serial ports on Teensy is use of code designed for Arduino Uno with Serial within the code. On Teensy, Serial accesses the USB only. USB and Serial1 (pins 0 & 1) are not shared on Teensy. For hardware serial ports, Serial1, Serial2, Serial3, Serial4, Serial5, Serial6, Serial7 or Serial8 must be used.
    Hopefully this will make it clearer in the future.

  10. #10
    Senior Member jim lee's Avatar
    Join Date
    Dec 2016
    Location
    Anacortes, WA
    Posts
    168
    Hopefully this will make it clearer in the future.
    Yes that would! Although I didn't even know that that information existed. Or, there was a link to something like that. In fact, Once I look at it, I see there's all the info I was looking for. But how would I have ever found it on my own? I can't find it under products, or teensy.. I looked all over. I can find the pinout picture, and that's actually what I've been using for 99% of my reference material. That picture is a life saver for me!

    Anyway, thank you all for the info. Adafruit finally got back to me. So I think I now have all the bits to my puzzle. They say that their Serial1 is for pins 0 & 1 only as well. So I now can hook hardware to hardware while keeping serial monitor (debugging) working for both.

    -jim lee

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •