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

Thread: Is it possible to invert the serial logic on Teensy 3?

  1. #1

    Is it possible to invert the serial logic on Teensy 3?

    Hi, i'm trying to read a sensor who uses the SDI-12 protocol, it's a serial data 7E1 with negative logic.
    I'm wondering if it's possible to set a register to invert the logic of the serial on the Teensy 3. I took a look at the MK20DX128 documentation but I didn't find that option.

    Thanks.

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    25,210
    The hardware seems to support it.

    Look at the RXINV bit in UARTx_S2 (section 45.3.6 on page 1061-1063) and the TXINV bit in UARTx_C3 (section 45.3.7 on page 1063-1065).

    I have not personally tried using this feature, so I can't help... other than pointing you to these specific parts of the reference manual.

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    25,210
    Also, please pay attention to the text at the beginning of both of those sections, regarding the limitations as to when you may change those bits.

  4. #4
    Thank you very much, I'll try to change it and then I'll post some feedback here.

  5. #5
    It worked, I made UART0_C3 = 16 and the logic was inverted.

    void setup()
    {

    delay(1000);
    Serial.begin(9600); // USB is always 12 Mbit/sec
    Serial1.begin(1200);
    UART0_C3 = 16;

    }

    In the image it's possible to see in green an Arduino signal and in red the Teensy 3 inverted signal.

    Click image for larger version. 

Name:	5Hp28ZF.jpg 
Views:	324 
Size:	76.6 KB 
ID:	493

Posting Permissions

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