This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Handling 7 bit UART



If I set UC7BIT of UCAxCTL - my UART will now be in 7 bit mode - so the MSB of any 8 bit character I put in gets dropped - and the MSB of any 8 bit character I extract will always be 0.

SLAU208M:

The receive-data buffer is user accessible and contains the last received
character from the receive shift register. Reading UCAxRXBUF resets the
receive-error bits, the UCADDR or UCIDLE bit, and UCRXIFG. In 7-bit data
mode, UCAxRXBUF is LSB justified and the MSB is always reset.

The transmit data buffer is user accessible and holds the data waiting to be
moved into the transmit shift register and transmitted on UCAxTXD. Writing to
the transmit data buffer clears UCTXIFG. The MSB of UCAxTXBUF is not used
for 7-bit data and is reset

7 Bit mode lends its self find to unsigned ASCII data because there are only 128 possible characters and you are taking an always unsigned signed character and throwing out the sign bit. This makes your data rate baud * 7/9 instead of baud * 8/10 - assuming 8N1 and 7N1.

However, I am moving raw binary data. How do people in my position commonly move data using 7 bit mode - I am only asking cause I have some software that supports the option and I am not sure how they do it if for some reason I wanted to interface with it that way.

Would I accumulate 8 characters of data, concatenate them together discarding the MSB (which is always 0), and then extract out 7 characters? Thus the LSB of the first 8 bit character would get sent at the MSB on the next 7 bit character, and so on?

This is mostly a curiosity if anyone has heard about it - I can't imagine needing to actually do this.

  • Nick Waters said:
    However, I am moving raw binary data. How do people in my position commonly move data using 7 bit mode

    They typically don't. 7-bit mode is a holdover from the old terminal days when you sent plain ASCII characters.

    If you need to move binary data, use 8-bit mode.

  • Understood, but perhaps I should explain where I am coming from w/ the UART questions I have been posting around here :).

    I am working on a SCADA communications product (DNP3) - and some SCADA master software I have seen in gives the option to use 7 bit data - which doesn't really make sense to me. So I was wondering if anyone has run into this. Perhaps this is a question to pitch to some of those software vendors - but I was wondering if there was any "defacto standard" in play here that I am not aware of and wasn't able to find when googling it.

    This is something we included in our UI as an option (because our SCADA software had it) - and now we are in the thick of things and thinking we will probably just remove the option on the UI because we can't imagine anyone on earth actually using this. I am just wondering how I would attack this beast if one customer came and I said "I will order 5,000 units, but you must include this feature to interface with my legacy thingamajig from 1982".

  • Yes. Biggest puzzle of modern computing - how they manage to send anything that is bigger than single bit, over any serial interface? :)

    Simple answer: both parties know the rules how huge pile of data will be split into smaller chunks. The rules can be and mostly are different for each kind of application specifics.

  • Ilmars said:
    both parties know the rules how huge pile of data will be split into smaller chunks.

    Indeed. It dfepends on definition. Even on 8 bit data, there is no universal standard telling whether LSB or MSB is sent first (the MSP supports both). And for 16 bit or 32 bit values, are they little endian or big endian? Again, this is something that has to be agreed to by both sides.

    7 bit is is indeed faster if data is only 7 bit. Giving 11% more throughput on a plain ASCII terminal (well with 300Bd, this was a somewhat important difference, but from 1200Bd on, data was already coming in faster than one could read).

    If the 8th bit has to be sent with the next anyway, it makes the throughput even lower, because you then have a start and stop bit every 7 and not every 8 bit. And (considering the usual support for 8 bit data in any involved CPU) increases the handling of the data by bit-shifting and recombining algorithms.

**Attention** This is a public forum