1

I have ported a project from arduino Due to a teensy 4.1

In the project I read data from a sensor which speaks serial at 7 databits, no parity and 2 stopbits (no configurable).

Now it seems that teensy does not support this dataformat. Could I read my sensor in a way using teensy 4.1? I could maybe use softwareserial but the format does not seem to be configurable.

3
  • maybe try to use SERIAL_7N1 | SERIAL_2STOP_BITS, I don't see why it shouldn't support it – KIIV May 12 at 12:57
  • Hi @KIIV I tried but it doesn't compile: 'SERIAL_7N1' was not declared in this scope. 7 databits with no parity is not listed in the supported dataformats. – Sven Onderbeke May 12 at 13:31
  • 1
    Weird, how about 8N1 with masking that last bit to logic 1, so it'll look like 2 stop bits? – KIIV May 12 at 13:48
0

There is no difference between 7N2 and 8N1. You just have the most significant bit of your data value being the first of the two stop bits.

To transmit just set the most significant bit to 1.

To receive just ignore the most significant bit.

For example:

Serial.write(val | 0x80);

And:

uint8_t val = Serial.read() & 0x7F;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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