This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

configure UART1 for using hardware flow control in Linux

Hi all!

On custom board, based on DM816x EVM, I have UART1 connected to the ADM3078EARZ (http://pdf1.alldatasheet.net/datasheet-pdf/view/164508/AD/ADM3078EARZ.html). I wrote test application to check that data is transmitted. I see (by oscilloscope) data on UART1_TXD line, but I can not see what RTS line is driven (RTS connected to the DE on ADM3078) and data not be transmitted. I use default linux kernel and MUX settings for UART1 from EZSDK_5_04_00_11.

Please tell me how I can drive RTS line to enable DE signal on ADM3078EARZ?

May be I have error in test application, or need additional MUX settings for CTS/RTS pins?

Thank you.

Application File: 5008.main.cpp

usage: ./app /dev/ttyO1

My application code: 

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <signal.h>
#include <string.h>
#include <termios.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/signal.h>
#include <sys/types.h>
//-----------------------------------------------------------------------------
#define BUF_SIZE 4
//-----------------------------------------------------------------------------
volatile int exit_flag = 0;
//-----------------------------------------------------------------------------
void exit_app(int sig)
{
exit_flag = 1;
}
//-----------------------------------------------------------------------------
int main(int argc, char *argv[])
{
int err = 0;

signal(SIGINT, exit_app);

if(argc == 1) {
printf("usage: %s <device name>\n", argv[0]);
return -1;
}
printf("Start testing device %s\n", argv[1]);

int fd = open(argv[1], O_RDWR | O_NOCTTY | O_NDELAY);
if(fd < 0) {
fprintf(stderr, "%s(): Error open device %s\n", __FUNCTION__, argv[1]);
return fd;
}

printf("Open device %s\n",argv[1]);
 struct termios options;
 tcgetattr(fd, &options);
 cfsetispeed(&options, B115200);
cfsetospeed(&options, B115200);
 options.c_cflag &= ~PARENB;
options.c_cflag &= ~CSTOPB;
options.c_cflag &= ~CSIZE;
options.c_cflag |= CS8;
options.c_cc[VMIN] = 0;
options.c_cc[VTIME] = 1;
options.c_cflag |= (CLOCAL | CREAD | CRTSCTS);
 if(tcsetattr(fd, TCSANOW, &options)!= 0) {
 printf("Error setup serial port\n");
close(fd);
return -1;
}

unsigned char outBuf[BUF_SIZE];
unsigned char inBuf[BUF_SIZE];

for(int i=0; i<BUF_SIZE; i++) {
outBuf[i] = i;
inBuf[i] = 0;
}

do {

printf("Press Enter to write data\n");
getchar();

if(exit_flag) {
break;
}

err = write(fd, outBuf, sizeof(outBuf));
if(err < 0) {
printf("Error write device: %s\n", strerror(errno));
break;
} else {
printf("Write %d bytes\n", err);
}

} while (1);
 close(fd);
 return err;
}
  • I change MUX settings in u-boot,  and Linux (as stated in TI81XX_PSP_User_guide.pdf).
    in u-boot:
    void set_muxconf_regs(void)
    {
    ...
    /* UART1 Muxconfig */
    __raw_writew( M0, UART1_RXD);
    __raw_writew((M0 | EN), UART1_TXD);
    __raw_writew((M0 | PTU | EN), UART1_RTSN);
    __raw_writew((M0 | PTU), UART1_CTSN);
    }

    in Linux (in two places): 
    first place:
    void omap2_init_devices()
    {
    omap_mux_init_signal("uart1_rxd", OMAP_MUX_MODE0);
    omap_mux_init_signal("uart1_txd", OMAP_MUX_MODE0 | OMAP_PULL_ENA);
    omap_mux_init_signal("uart1_rtsn", OMAP_MUX_MODE0 | OMAP_PULL_UP | OMAP_PULL_ENA);
    omap_mux_init_signal("uart1_ctsn", OMAP_MUX_MODE0 | OMAP_PULL_UP);
    }
    second place in board_mux array:
    static struct omap_board_mux board_mux[] __initdata = {
    /* PIN mux for non-muxed NOR */
    TI816X_MUX(TIM7_OUT, OMAP_MUX_MODE1), /* gpmc_a12 */
    //TI816X_MUX(UART1_CTSN, OMAP_MUX_MODE1), /* gpmc_a13 */ - old settings
    //TI816X_MUX(UART1_RTSN, OMAP_MUX_MODE1), /* gpmc_a14 */ - old settings
    TI816X_MUX(UART1_RXD, OMAP_MUX_MODE0), /* uart1 */
    TI816X_MUX(UART1_TXD, OMAP_MUX_MODE0 | OMAP_PULL_ENA), /* uart1 */
    TI816X_MUX(UART1_RTSN, OMAP_MUX_MODE0 | OMAP_PULL_UP | OMAP_PULL_ENA), /* uart1 */
    TI816X_MUX(UART1_CTSN, OMAP_MUX_MODE0 | OMAP_PULL_UP), /* uart1 */
    ...
    }

    But I can't see that RTS/CTS signals changing.
    Please help me to configure UART1 properly with hardware flow control CTS/RTS signals. I try to use several examples from google and e2e but has no result.

    Thank's  for any advise or suggestions.