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

Status
Not open for further replies.

pablotcarreira

New member
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.
 
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.
 
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.
 
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.

5Hp28ZF.jpg
 
Status
Not open for further replies.
Back
Top