HOME
  • GM-3568JHF
  • M4-R1
  • M5-R1
  • SC-3568HA
  • M-K1HSE
  • CF-NRS1
  • CF-CRA2
  • 1684XB-32T
  • 1684X-416T
  • C-3568BQ
  • C-3588LQ
  • GC-3568JBAF
  • C-K1BA
Shop
  • English
  • 简体中文
HOME
  • GM-3568JHF
  • M4-R1
  • M5-R1
  • SC-3568HA
  • M-K1HSE
  • CF-NRS1
  • CF-CRA2
  • 1684XB-32T
  • 1684X-416T
  • C-3568BQ
  • C-3588LQ
  • GC-3568JBAF
  • C-K1BA
Shop
  • English
  • 简体中文
  • GM-3568JHF

    • 1. Introduction

      • GM-3568JHF Introduction
    • 2. Quick Start

      • 01 Environment Construction
      • 02 Compilation Instructions
      • 03 Burning Guide
      • 04 Debugging Tools
      • 05 Software Update
      • 06 View information
      • 07 Test Command
      • 08 Application Compilation
      • 09 Source code acquisition
    • 3. Peripherals and Interfaces

      • USB
      • Display and touch
      • Ethernet
      • WIFI
      • Bluetooth
      • TF-Card
      • Audio
      • Serial Port
      • CAN
      • RTC
    • 4. Application Development

      • 01 UART read and write case
      • 02 Key detection case
      • 03 LED light flashing case
      • 04 MIPI screen detection case
      • 05 Read USB device information example
      • 06 FAN Detection Case
      • 07 FPGA FSPI Communication Case
      • 08 FPGA DMA read and write case
      • 09 GPS debugging case
      • 10 Ethernet Test Cases
      • 11 RS485 reading and writing examples
      • 12 FPGA IIC read and write examples
      • 13 PN532 NFC card reader case
      • 14 TF card reading and writing case
    • 5. QT Development

      • 01 ARM64 cross compiler environment construction
      • 02 QT program added automatic startup service
    • 6. Others

      • 01 Modification of the root directory file system
      • 02 System auto-start service

01 UART read and write case

Case Introduction

This case aims to introduce how to test the UART serial communication function on the development board.

The serial ports supported by the development board and their corresponding device nodes are shown in the following table.

Serial PortDevice Node
RS232 UART0ttyS0
TTL UART0ttyS4
RS485 UART7ttyS7
RS485 UART8ttyS8

The following will take TTL UART0 as an example to explain the test process in detail, including hardware connection, software configuration, and specific steps to implement serial port read and write functions.

Pre-test preparation

Before you begin testing, follow these steps to prepare:

Hardware Hookup

Use a USB to TTL serial port module to connect the PC to the TTL UART4 interface of the development board. The specific location of the TTL UART4 interface is shown in the figure. Please ensure that the connection is correct and stable.

UART_RW_2

Software Preparation

Open the device manager and confirm that the device has been correctly identified. After the first connection, you may need to restart the PC to identify the correct device name "XR21V1410 USB UART", as shown in the figure.

UART_RW_4

Open the serial port debugging tool on the PC (see "Quick Development/Debugging Tool Installation" for window debugging tool installation) and select the corresponding serial port number, for example, COM13 in this case. Set the baud rate to 115200, the data bit to 8, and no parity bit. The configuration is as shown in the figure below. Click "Open" to create the connection.

UART_RW_5

Operation process

TTL UART4 serial port test


Copy the executable program smdt_uart_rw in the bin directory of this case (05-Development Materials\Software Development Materials\linux_demo\smdt_uart_rw\bin) to the development board file system (the source code can be viewed in the src path). Open the terminal and execute the following command to switch to the directory where the smdt_uart_rw executable program is located.

cd ‘the file's directory’

After switching, you can run the command "ls" to check whether the smdt_uart_rw executable program is in the current directory.

ls

If the executable file smdt_uert_rw exists in the current directory, continue to perform the following operations: Enter the following command to modify the file permissions.

chmod 777 smdt_uart_rw

After modifying the permissions, you can enter the following command to check whether the modification is successful.

ls -ld smdt_uart_rw

The execution result is: -rwxrwxrwx 1 root root 19016 Mar 3 09:55 smdt_uart_rw.

-rwxrwxrwx means the permissions have been modified successfully, the file can be executed, and you can continue with the following operations.

Continue to enter instructions and view program parameter information.

./smdt_uart_rw -h

The result after execution is as follows:

UART_RW_3

Development board receiving


Enter the following command and wait for receiving data from the PC

./smdt_uart_rw -d /dev/ttyS4 -r -s 9

Use the serial port debugging tool on the PC to send "ShimetaPi".

UART_RW_6

The development board debugging serial port terminal will print the received data.

UART_RW_7

Development board sent

Execute the following command, the development board sends data to the PC through the UART4 serial port, and the data sent is "012345670".

./smdt_uart_rw -d /dev/ttyS4 -w -s 9
UART_RW_8

The serial port debugging tool will receive the following data.

UART_RW_9
Edit this page on GitHub
Last Updated:
Contributors: zsl, zwhuang
Next
02 Key detection case