Page 1 of 1

Do i need to set anyhting to make a port TX or RX

Posted: Sun Apr 05, 2009 1:28 pm
by IAB48
Hi
how to i tell a port that it is being used for RS232 comms rather than a standard digital port. although this is a generic question the chip I am using at present is the 16F627.

Thanks
Ian B

Re: Do i need to set anyhting to make a port TX or RX

Posted: Sun Apr 05, 2009 3:54 pm
by Sean
Hi Ian,

If you are using Flowcode, all the necessary port configuration code is included when the RS232 component (or any other component) is added to the flowchart. You should avoid any additional program control of the associated i/o pins (RB1 and RB2 on the 16F627, and the flow control pins if hardware handshaking has been enabled).

Reading or writing the other Port B pins should be done with the single bit versions of the i/o commands, or the mask property used to exclude RB1 and RB2 - preventing them from being affected.

Re: Do i need to set anyhting to make a port TX or RX

Posted: Wed Aug 26, 2009 10:14 am
by jadiflow
Hi Sean or Ben,

This is exactly the question I also have. To confirm, if i have an RS232 component attached using hardware flow control, I should not even try to read any of the pins TX, RX, CTS, RTS to check status?

Jan Didden

Re: Do i need to set anyhting to make a port TX or RX

Posted: Wed Aug 26, 2009 10:39 am
by Sean
There should be no problems reading pins that are already configured as inputs by other components.

Attempting to read pins that need to be configured as outputs will cause problems. Flowcode will re-configure the pin as an input by writing to the TRIS (PIC) or DDR (AVR) register before reading the PORT (PIC) or PIN (AVR) register, and will leave the pin as an input after the instruction has been completed.

It is possible to read the state of an output pin by accessing the PORT or PIN register directly using C code and avoiding any writes to the associated TRIS/DDR register.

Re: Do i need to set anyhting to make a port TX or RX

Posted: Wed Aug 26, 2009 10:42 am
by Benj
The RS232 operation is fairly transparent and you can use the component by simply using the component macros. Things like flow control and pin setup are performed automatically for you (as long as the pins are defined correctly inside the component connections property page).

Re: Do i need to set anyhting to make a port TX or RX

Posted: Thu Aug 27, 2009 8:55 am
by jadiflow
Ahhh yes, but I use the UART to communicate with a transcoder component (for a wireless link). The setup of the transcoder to make it enter a defined serial I/O state is to manipulate some of the UART pins as follows (and the order is important):

- assert TX
- assert RTS
- delay 50mS (transcoder enters serial mode @ 9600bd)
- send serial bytes/command: fc sendbyte macro
- delay 1mS (processing)
- negate RTS (to make the transcoder emit ack/response)
- read ack/response: fc readbyte macro
...

So you see I need to manipulate those pins, and then do the component macro. It seems that for this to work, the component macro should (re)configure the UART pins with each call to readbyte or sendbyte. Any idea how to solve this?

Edit: I just looked at the .c code generated for the uart macro and it appears that RTS and TX are only used as an output throughout. Does that mean that I can assert/negate them at will without interfering with the uart operation?

Jan Didden