Question

My brain is fried, so I thought I would pass this one to the community.

When sending 1 character to my embedded system, it consistently thinks it receives 2 characters. The first received character seems to map to the transmitted character (in some unknown way) and the second received character is always 0xff.

Here is what I observed:

Tx char (in hex)    Rx character (in hex), I left out the second byte (always ff)
31                    9D
32                    9B
33                    99
61                    3D
62                    3B
63                    39
64                    37
65                    35
41                    7D
42                    7B
43                    79

I have check my clocks and them seem to be OK. The only difference between this non working version and the previous version is that i am now using a RS485 chip.

I have traced the signal all the way up to the MCU and it looks fine (confirmed the bit value on the RX pin)

Was it helpful?

Solution

The first received character seems to map to the transmitted character (in some unkown way)

In each case the TX byte is shifted left 1 bit then inverted.

For instance:

31 = 00110001 9D = 10011101

0x31 << 1 = 01100010

the complement of 01100010 is 0x9D

I checked a couple of the others, looks to be the same for them all. I don't know where the second byte is coming from but it could be a result of the likely signal inversion thats going on.

RS485 uses differential signaling. It smells like you used the inverted output of the chip and plugged into a RS232 input.

I have traced the signal all the way up to the MCU and it looks fine (confirmed the bit value on the rx pin)

What signal did you use as the ground reference?

OTHER TIPS

RS485 is quite different from RS232 at the electrical level (differential versus single ended and +/-6V versus +15/-3V) - are both sides of your communication link using the same protocol?

If it's RS485 have you got the "default state" of the bus set correctly? How about the correct number of stop bits?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top