I have a project which consists of a pair of microcontrollers (PIC16F877A and PIC16F777 to be exact). These function as a unit, with one being the "master" and the other a "slave". They respond to commands sent on a serial port. Electronically they're hooked up with the input going to the master CPU's UART input pin, so it can receive commands and act on them. The master CPU's UART output pin is connected directly to the slave CPU's UART input pin so that it can send commands on to it when necessary.
Unfortunately, it looks like the slave isn't waiting for input on its UART. I'm guessing that it's seeing noise (and thus endless framing errors) on the line, confusing it. So now I'm not sure if the master's properly driving it when not explicitly sending a byte or something.
So in a setup like this, do I need to have a pull-up or pull-down resistor on the serial line between the CPUs or something?
___________ ___________
|\ | CPU 1 | | CPU 2 |
| \ | | | |
Input --| >----| UART IN | ? | |
| / | UART OUT |-----| UART IN |
|/ |___________| |___________|
RS-485
Receiver
Any hints would be appreciated. Thanks!
Crossposted to
electronics and
microcontroller
ETA: Solution was found. Thanks to all the suggestions from people here! Actually, it turned out I had the hardware and configuration bits all correct, but just needed to refine the timing a little bit. It turns out that to use the USART, you SET the TRIS bits for both serial pins. Then when you turn on the serial port, it takes over management of the pins, tri-stating the TX line when the serial transmitter is disabled, and driving the output (in spite of TRISC) when the transmitter is enabled.
It also turned out that I didn't need a pull-up or -down resistor, at least in this case. Once I got the timing right, so that the master CPU's transmitter was on and driving the line way before the slave CPU's receiver was turned on and listening, everything worked out just fine.