0
\$\begingroup\$

I am writing data serial monitor via hal_uart_transmit and it works fine, but when I monitor same serial bit pattern in logic analyzer I see extra two bits have the logic high state, why is that?

for example on the serial monitor, I get 5 in decimal, in a logic analyzer, I get 00110101 it should be 00000101 isn't it? not only for numbers, but I also got this issue for any string as well.

\$\endgroup\$
1
\$\begingroup\$

You are seeing the numeric value 5 encoded as the ASCII character '5' which has the hex value 0x35

00000101 binary is 5, a value

00110101 binary is 0x35 (48 + 5 decimal) which is the character code for a printable '5'

Also worth remembering that if you try to decode the logic analyzer or scope waveform by eye, it will be sent LSB first, and there will be additional framing.

\$\endgroup\$

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.