Home/Support/Support Forum/RTS Toggle does not work on ME9210
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

RTS Toggle does not work on ME9210

0 votes

What i'm doing wrong here, RTS does not toggle between high and low for sending. I will appreciated any help !!

This is my code.

printf("Starting port %s\n", COM0);

handle = open(COM0, O_RDWR | O_NONBLOCK,0);
if (handle <= 0)
printf("Failed to open %s\n", COM0);

if (tcgetattr(handle, &amp;tios) < 0)
printf("tcgetattr failed\n");

tios.c_cflag = CREAD | CS8 | CRTSTOGGLE;
tios.c_iflag = 0;
tios.c_cc[VPREDELAY] = 1;
tios.c_cc[VPOSTDELAY] = 1;
tios.c_oflag = 0;
tios.c_xflag = 0;
tios.c_lflag = 0;

cfsetospeed(&amp;tios, serl_baudrate);

if (tcsetattr(handle, TCSANOW, &amp;tios) < 0)
printf("tcsetattr failed\n");

// read the data from serial port
bytes_read = read(handle, &amp;by, 1);
if (bytes_read > 0)
// echo the sent data back to sender
write(handle, &amp;by, 1);
asked Mar 15, 2013 in NET+OS by zaricd New to the Community (2 points)
recategorized Sep 20, 2013 by tuxembb

Please log in or register to answer this question.

2 Answers

0 votes
Possibly you have unintentionally enabled two conflicting mechanisms!

I have left the following values at their defaults (presumably zero):
tios.c_cc[VPREDELAY] = 1;
tios.c_cc[VPOSTDELAY] = 1;

The delays are measured in system ticks, which is unnecessarily slow, IMO. (On a quick look in the driver code they appear to be supported - probably treating the RTS pin as a generic output - maybe you need to explicitly set the RTS pin as an output).

If you use the CRTSTOGGLE function when the above delays are zero, it enables a hardware function in the UART.
To give some setup and hold time on RTS, I've modified camry_serial.h, about line 20, as follows:

#define RTSEN ((1 << 19) | 0xf) /* extends RTS a little either side of TxData */

You also need to configure the RTS pin as having a function associated with the UART:
NAconfigureGPIOpin(5,NA_GPIO_SELECT_MUX_FUNC0,1); // RTS hooked into UART, normally disabled

This has been working OK for me for a long time.
answered Mar 15, 2013 by steved2 Seasoned Professional (182 points)
0 votes
Thanks Steve

It is working .
I added next lines :

NAInvertGPIOpin(5, TRUE);
answered Mar 16, 2013 by zaricd New to the Community (2 points)