Skip to main content

3. UART

3.1 Enabling Serial Port​

In Core3566, UART2 is designated as the debug serial port, and UART3, UART4, UART5, and UART7 are also available. You can use the luckfox-config tool to enable the relevant configuration.

  1. Open the luckfox-config tool in the terminal:

    sudo luckfox-config
  2. Select Interface Options:

  3. Select UART:

  4. Select the UART interface you want to enable, here we take UART7 as an example:

  5. After selecting Enter to confirm, there will be a prompt that PWM14M0 and PWM15M0 are not available. This is because using the UART4 function prevents the simultaneous use of the PWM interface for serial communication:

3.2 Testing the Serial Port​

  • Taking UART7 as an example, after successfully enabling it, we use the command to view UART7:

    root@linaro-alip:/home/linaro# ls /dev/ttyS*
    /dev/ttyS1 /dev/ttyS7
  • Use the stty tool to query its communication parameters:

    linaro@linaro-alip:~$ stty -F /dev/ttyS7
    speed 9600 baud; line = 0;
    -brkint -imaxbel
  • Modify the baud rate, where ispeed is the input speed and ospeed is the output speed:

    stty -F /dev/ttyS7 ispeed 115200 ospeed 115200
  • Turn off echo:

    stty -F /dev/ttyS7 -echo

3.2.1 Communication with a Windows Host​

  1. Connect one end of the serial module to the computer and the other end to pins 9 (GND), 13 (UART7_TX), and 15 (UART7_RX) on the CM4-IO-BASE-B board.

  2. Download and open MobaXterm, select Serial, and set the baud rate (default is 9600, please adjust it according to your actual modified value).

  1. Execute the following commands in the terminal on the development board to write the strings "Hello" and "world !" to the terminal device file using the echo command:

    echo Hello > /dev/ttyS7
    echo "world !" > /dev/ttyS7
  2. The serial debugging assistant on Windows will receive the content: