# Decode/Analyse the following UART signals

I have sent a 2 and a 9 using UART. The baud rate is 9600, there is no parity, and it has 8 data bits.

As we know 9 is represented as 1001 in binary. However, this is what I get from my UART signal:

A 2 is represented as 0010 but this is what I get from my UART signal: I know I have to pay attention to the start bit, but other than that, I have a hard time seing the logic in this signal.

NOTE:

The signal works, but I just need help analysing it.

• Without even looking at the waveform, you may be confusing binary numbers and ASCII character codes, eg, the numeric value 2 vs the character '2' which has the ascii code 0x32. Also please don't use random tags, tags are for what a question is about now what was tangentially involved but plays no part in your post. – Chris Stratton May 25 '20 at 16:23
• Your scope looks modern enough to have UART decoding, although perhaps it's also new enough that you have to pay for the privilege. – pipe May 26 '20 at 22:27

Let's annotate your first scope shot. When we do this take note that the lowest order bit of the binary value is transmitted first. Conventional notation in this field is to order the bits in a byte like this:

[Bit 7][Bit 6][Bit 5][Bit 4][Bit 3][Bit 2][Bit 1][Bit 0]

So when I annotate and then evaluate the bit positions are flipped from the positions shown on the annotated scope shots.

The bit pattern represented there is 0b00111001.

That is the same as 0x39.

0x39 is the ASCII code for a '9' character.

Let's do the same for your second scope shot.

Here the bit pattern is represented as 0b00110010.

That is same as 0x32.

0x32 is the ASCII code for the '2' character.

• Start bits are always a zero level bit and are the same width. Your second pictures red lines are actually marking bit 1. Bit 0 is not skipped. – Michael Karas May 25 '20 at 16:53
• Stop bits are always a one level bit and are the same width. The stop bit is not part of the UART 8-bits data. – Michael Karas May 25 '20 at 16:54
• No. The start bit is clearly marked in my annotations and is not Bit 0. – Michael Karas May 25 '20 at 16:56
• You are reading them backwards. LSB means least significant bit comes first. You need to invert them left to right. – evildemonic May 25 '20 at 17:11
• I denoted the bit numbers in the pictures. In this discipline bit 0 is the least significant bit. – Michael Karas May 25 '20 at 17:48

You probably sent an ASCII 9, not a binary 9. ASCII 9 is 0x39. Bits are sent LSbit first.

0011 1001 reversed is 1001 1100

UARTs usually send the least-significant bit first hence you get this for 9 and lower down for 2: -

UART character frame: -

• Oh misery, a downvote - anyone feel man-enough to own up to this? – Andy aka May 26 '20 at 12:20
• I didn’t downvote, but your answer is the only one that doesn’t mention ASCII. – Jacob Krall May 27 '20 at 22:04

First of all, those are not numbers 9 and 2, but ASCII character symbols '9' and '2', which equal to 0x39 and 0x32.

The bits are also sent LSB first. That's why you see a leading 0 start bit, and then 10011100 for '9' and 01001100 for '2'.

The 2 that you sent is actually the character two, not the decimal value of 2. The ASCII code for 2 is 0x32 or 0b00110010, which matches one of your images. Also, the bits are sent from LSB to MSB, so the levels you see on the 'scope would be 0,1,0,0,1,1,0,0 from left to right.