Page 1 of 1

RS232 application

Posted: Sun Apr 05, 2009 3:41 pm
by jadiflow
Hi,

Not entirely Flowcode, but there's so much intellect gathered here so here goes:

I have an application to interface a PIC through its UART to a component that has a bi-directional data i/o line. So, if I want to send data to the device I need to set a pin to make its data line an input; if I want to read from the device I need to clear that pin to make the data line an output. The device does implement RS232 protocol complete with internal baud rate generator.

So, I was planning to use a small ic switch to switch either the PIC TX or RX line to the bi-directional data line and toggle the switch with the same signal that toggles the data line between input and output. In flowcode I then have to bit-bang that switch control line before each serial send or serial receive macro call.

Would this work you think? Or would that interfere with the asynchronous send/receive which is not under program control?

Thanks,

Jan Didden

Re: RS232 application

Posted: Mon Apr 06, 2009 9:13 am
by Steve
I think it would work, but you will need to ensure that there is a layer of flow control on the communication protocol so you can guarantee that the bi-directional line is configured in the correct direction at the right time. Although this may not be absolutely necessary cecause the protocol may impose certain limitations such as the PIC must always initiate communication and the device will send a specific amount of data only when asked.

I think I've seen implementations of SPI where the input and output pins are connected together (using a suitable resistor) and then the single line can be used in a bidirectional way. Perhaps you could do the same with the UART pins, meaning you would not need a separate IC switch.