FAQ_MA35D1_UART maximum baud rate support

Post Reply
yhcheng3
Posts: 55
Joined: 02 Dec 2022, 10:46

01 Sep 2023, 17:11

Question :

UART maximum baud rate support


Answer.
According to the manual, the maximum baud rate can support 9.5MHz


Using non-os code to perform internal loop back testing can achieve the values described by TRM.

In Linux, our test situation is that the FIFO trigger level is set to 0x30, and the baud rate is 6Mbps. It is normal for the IoT board UART10 to short-circuit rx and tx for 2K Bytes to send and receive 100 times.

FIFO trigger level is set to 0x30 method:


1. Driver
ma35d1serial_startup() in output/build/linux-custom/drivers/tty/serial/ma35d1_serial.c

Code: Select all

serial_out(up, UART_REG_FCR, serial_in(up, UART_REG_FCR) | 0x10 | 0x20000);
Change to

Code: Select all

serial_out(up, UART_REG_FCR, serial_in(up, UART_REG_FCR) | 0x30 | 0x20000);
2. Device Tree
Modify output/build/linux-custom/arch/arm64/boot/dts/nuvoton/ma35d1.dtsi

Code: Select all

assigned-clocks = <&clk UART10_MUX>;
assigned-clock-parents = <&clk SYSCLK1_DIV2>;

uart10:serial@407A0000 {
                compatible = "nuvoton,ma35d1-uart";
                reg = <0x0 0x407A0000 0x0 0x10000>;
                interrupts = <GIC_SPI 95 IRQ_TYPE_LEVEL_HIGH>;
                clocks = <&clk UART10_GATE>;
                port-number = <10>;
                pdma-enable = <0>;
                assigned-clocks = <&clk UART10_MUX>;
                assigned-clock-parents = <&clk SYSCLK1_DIV2>;
                status = "disabled";
        };
3. Modify the baud rate

Code: Select all

static int open_port(const char *portname)
{
    struct sigaction sa;
    int portfd;
    struct termios to;

    if((portfd=open(portname,O_RDWR | O_NOCTTY)) < 0 )
    {
           printf("open serial port %s fail \n ",portname);
           return portfd;
    }

    /*get serial port parnms,save away */
    tcgetattr(portfd,&newtios);
    memcpy(&oldtios,&newtios,sizeof newtios);
    /* configure new values */
    cfmakeraw(&newtios); /*see man page */
    newtios.c_iflag |=IGNPAR; /*ignore parity on input */
    newtios.c_iflag &= ~(IXON | IXOFF | IXANY);
    //newtios.c_iflag |= (INPCK | ISTRIP); // for test

    newtios.c_oflag &= ~(OPOST | ONLCR | OLCUC | OCRNL | ONOCR | ONLRET | OFILL);

    newtios.c_cflag = CS8 | CLOCAL | CREAD;

    //newtios.c_cc[VMIN]=1; /* block until 1 char received */
    newtios.c_cc[VMIN]=0xff;

    newtios.c_cc[VTIME]=0; /*no inter-character timer */


    newtios.c_iflag |= CRTSCTS;

    /* register cleanup stuff */
    atexit(reset_tty_atexit);
    memset(&sa,0,sizeof sa);
    sa.sa_handler = reset_tty_handler;
    sigaction(SIGHUP,&sa,NULL);
    sigaction(SIGINT,&sa,NULL);
    sigaction(SIGPIPE,&sa,NULL);
    sigaction(SIGTERM,&sa,NULL);
    /*apply modified termios */
    saved_portfd=portfd;
    tcflush(portfd,TCIFLUSH);
    tcsetattr(portfd,TCSADRAIN,&newtios);

    ioctl(portfd, TCGETS2, &tio);
    tio.c_cflag &= ~CBAUD;
    tio.c_cflag |= BOTHER;
    tio.c_ispeed = 6000000;
    tio.c_ospeed = 6000000;
    ioctl(portfd, TCSETS2, &tio);

    return portfd;
}
4. Execute /uart_demo_rx_tx
script:

Code: Select all

#!/bin/sh

for i in $(seq 1 100)
do
  echo "Running command: $i"
  /uart_demo_rx_tx
  sleep 1
done

#MA35D1, #UART
.
Attachments
UART.png
UART.png (139.7 KiB) Viewed 27609 times

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 51 guests