Strange UART behavior

Hi all,

I've got a question about the UART on the Uno. I'm using it via an RS-485 chip to communicate with my car stereo head unit, and I've run into some strange behavior - I have to set the RX pin high at the start of my program or the Arduino can't talk to the head unit.

The stereo uses 9-bit serial so the sketch doesn't use the Arduino Serial library; the UART is manually set up using the relevant registers. I was under the impression that once enabled, the UART hardware takes care of the pin direction settings and such, so what's going on here?

I'm not particularly new to Arduino or embedded programming but some of the finer details still escape me. Is this down to the serial protocol or something to do with the AVR setup?

Thanks,
Stu

There’s a problem with your code.

There’s a problem in the schematic.

There’s a problem with your setup.

?

stutika:
Hi all,

I've got a question about the UART on the Uno. I'm using it via an RS-485 chip to communicate with my car stereo head unit, and I've run into some strange behavior - I have to set the RX pin high at the start of my program or the Arduino can't talk to the head unit.

The stereo uses 9-bit serial so the sketch doesn't use the Arduino Serial library; the UART is manually set up using the relevant registers. I was under the impression that once enabled, the UART hardware takes care of the pin direction settings and such, so what's going on here?

I'm not particularly new to Arduino or embedded programming but some of the finer details still escape me. Is this down to the serial protocol or something to do with the AVR setup?

Thanks,
Stu

If you are using MAX485, SN75176 etc, when you triState RO with RE. R0 falls to 0 volts, which the UART assumes is a START bit. And it starts building a 'Received' byte.

put a pullup resistor on the RX pin 4.7k will work.

Please post a schematic, and at least a protol description, and what you are sending and receiving.

Chuck.

chucktodd:
If you are using MAX485, SN75176 etc, when you triState RO with RE. R0 falls to 0 volts, which the UART assumes is a START bit. And it starts building a ‘Received’ byte.

put a pullup resistor on the RX pin 4.7k will work.

Please post a schematic, and at least a protol description, and what you are sending and receiving.

Chuck.

That would be it, thanks! Did not know that about the serial protocol.

I was about to try adding a pullup when it occurred to me that the Arduino has internal pullups. Sure enough, adding

pinMode(0, INPUT_PULLUP);

to setup makes it work as expected. Thanks for the tip!