3
\$\begingroup\$

I'm implementing a protocol which begins with an 88 µs break (low) and uses an 8-N-1 configuration.

The latter is easily set with UCSRnC, but is there a way to configure the UART hardware to detect the 88 µs break? Alternatively, how can I detect this in software?

\$\endgroup\$
8
  • 3
    \$\begingroup\$ If it is DMX512, just say so. \$\endgroup\$
    – Justme
    Commented May 18, 2023 at 8:17
  • 2
    \$\begingroup\$ Knowing what it is can be crucial to what to suggest, for example fixing your errors. DMX isn't 8N1. \$\endgroup\$
    – Justme
    Commented May 18, 2023 at 8:42
  • 1
    \$\begingroup\$ Because it isn't. My answer has the details. \$\endgroup\$
    – Justme
    Commented May 18, 2023 at 10:00
  • 1
    \$\begingroup\$ DMX is 8N2, per section 8.2 of the ANSI E1.11 – 2008 standard \$\endgroup\$
    – jonathanjo
    Commented May 18, 2023 at 10:58
  • 2
    \$\begingroup\$ Haha it is! ... please update your question to say so \$\endgroup\$
    – jsotola
    Commented May 18, 2023 at 14:23

2 Answers 2

6
\$\begingroup\$

You don't have to configure anything.

If there is a too long low pulse on receive wire, so that the stop bit is not idle, you get a framing error flag in the status register for the received byte.

So if it is a real break condition, you will receive a 0x00 byte, and then you need to check if this byte has a framing error.

It can't really measure how long the break condition was, so if you really need to measure it, you need to do it separately.

But for DMX512, detecting the framing error should be sufficent. DMX512 is not 8N1 but 8N2 framing, and AVR UART will only check the first stop bit.

If you want to check both stop bits, you could always use 9N1 framing on AVR and check the 9th bit yourself.

If you only want to receive with an AVR, because it does not require and check the second stop bit, you can still use 8N1 for reception, the receiving logic does not care if data on wire is 8N1 or 8N2, as for the receiver logic, there's just always one idle bit before start bit. But the transmitter logic has to generate 1 or 2 stop bits before starting next frame.

\$\endgroup\$
3
\$\begingroup\$

There are a number of open-source implementations which you can fruitfully study for techniques.

As well as the obvious busy-loop which often isn't suitable because of other constraints, you can use the Framing Error detection.

For example, Matthas Hertel's DMXSerial Arduino library uses this technique. Look at _DMXReceived() in DMXSerial.cpp that repository.

Breaks are sent rather elegantly, by changing the baud rate to something slow and sending a zero. Search for BREAKSPEED in that file.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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