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

Thread: Serial Defaults to 1?

  1. #1
    Junior Member
    Join Date
    Aug 2021

    Serial Defaults to 1?


    I've got a 3.2 setup to transmit serial communication through Serial1 with the following commands

    uint8_t message[3] = {0x00, 0x01, 0x00};

    Serial1.begin(4800, SERIAL_8N1_RXINV_TXINV);
    Serial1.write(message, 3);

    The output looks like this:

    Click image for larger version. 

Name:	Teensy32_InvertedTransmit_0x00_0x01_0x00_2.jpg 
Views:	16 
Size:	197.8 KB 
ID:	25565

    I thought with SERIAL_8N1_RXINV_TXINV that 0 = LOW and 1 = HIGH and default (not transmitting) would be the same as 0. It seems like in-fact 0=HIGH, 1=LOW and default (not transmitting) is the same as 1 (LOW). Is there a reason for this functionality? If I need default (not transmitting) to equal 0 is it best I bitbang the output myself?

    The same output without SERIAL_8N1_RXINV_TXINV looks like this:

    Click image for larger version. 

Name:	Teensy32_Transmit_0x00_0x01_0x00_2.jpg 
Views:	19 
Size:	258.9 KB 
ID:	25566

    Any assistance in clarifying this is greatly appreciated.


  2. #2
    Senior Member
    Join Date
    Jul 2020
    mark = 1, space = 0 for normal TTL serial. Inbetween characters the line is held in the mark state. Start bits are space,
    stop bits are mark.

    TXINV just swaps those (which is like RS232 apart from not being bipolar).

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Quote Originally Posted by SpencerWF View Post
    Any assistance in clarifying this is greatly appreciated.
    It's not just Teensy. Virtually all UART chips and microcontrollers with TTL level signals use logic high for the inactive state. It's a de-facto standard that goes back at least 40-some years (maybe much longer?)

    The voltage levels used by RS-232 are an actual standard. It's well understood the TTL level signals are inverted from RS-232, as most of the earliest transceiver circuits were based on a single transistor which inverted the signal.

    Is there a reason for this functionality?
    For modern parts, the reason mostly amounts to keeping compatibility with countless prior parts.

    Before CMOS became mature in the late 1980s, there was indeed a technical reason. With NMOS or NPN-only bipolar transistor chips, logic low used a lot more power than logic high. Virtually everything from that era was designed using active low signals.

Posting Permissions

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