Go Down

Topic: Strange UART behavior (Read 130 times) previous topic - next topic

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

/dev

<Looks at code>  There's a problem with your code.

<Looks at schematic>  There's a problem in the schematic.

<Looks at photo>  There's a problem with your setup.

?

chucktodd

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.

stutika

#3
Apr 17, 2016, 05:03 pm Last Edit: Apr 17, 2016, 05:23 pm by stutika
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

Code: [Select]

pinMode(0, INPUT_PULLUP);


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

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy