DSBOX-NX2 (Rev. 1.1) Serial Communication Interfaces Tutorial - Forecr.io

DSBOX-NX2 (Rev. 1.1) Serial Communication Interfaces Tutorial

Jetson Xavier NX

18 May 2021
WHAT YOU WILL LEARN?

1- The pinout of I/O connector  

2- Installing GtkTerm 

3- Testing the serial communication interfaces 

ENVIRONMENT

Hardware: DSBOX-NX2 (Rev. 1.1)

OS: JetPack-4.5 & JetPack-5.0.2



First, let's look over the IO connector. On the connector, there are 4 serial communication pins and 2 digital ground pins. When using a serial communication interface, you should always double-check which ground pin you are using. Also, use a digital ground for serial communication applications.


To test all serial communication interfaces, open a new terminal and install the GtkTerm program for ease of use (make sure Ethernet cable is connected). Then run the GtkTerm program with arguments. On the host side, you can use TeraTerm or Putty for Windows; GtkTerm for Ubuntu OS. You can install GtkTerm with this terminal command:


sudo apt install gtkterm


RS232 Test


To test RS232 functionality, we use a USB-Serial adapter. Connect that adapter to the USB port of the host PC and install its driver software if necessary. To the other side of the adapter, connect your device’s RS232 pins with cross-connection (Rx to Tx, Tx to Rx). You can find the hardware pins below. For ground connection, use GND_DIGITAL pin.


After proper connection, you should do pin multiplexing on your device to use serial port as RS232. 


For JetPack-4.x

To do this, open new terminal then type these commands below.



sudo sh -c "echo 424 > /sys/class/gpio/export"
sudo sh -c "echo 436 > /sys/class/gpio/export"
sudo sh -c "echo out > /sys/class/gpio/gpio424/direction"
sudo sh -c "echo out > /sys/class/gpio/gpio436/direction"
sudo sh -c "echo 0 > /sys/class/gpio/gpio424/value"
sudo sh -c "echo 0 > /sys/class/gpio/gpio436/value"

For JetPack-5.x

Open a new terminal then type these commands below.



sudo sh -c "echo 443 > /sys/class/gpio/export"
sudo sh -c "echo 453 > /sys/class/gpio/export"
sudo sh -c "echo out > /sys/class/gpio/PR.00/direction"
sudo sh -c "echo out > /sys/class/gpio/PS.04/direction"
sudo sh -c "echo 0 > /sys/class/gpio/PR.00/value"
sudo sh -c "echo 0 > /sys/class/gpio/PS.04/value"


If you are using GtkTerm on Ubuntu, run these commands below. If you have done everything correctly you could see your keyboard presses on the other machine's serial terminal.


sudo gtkterm -p /dev/ttyTHS0 -s 115200


RS422 Test


To test RS422 functionality, we used a USB-Serial adapter. Connect that adapter to the USB port of the host PC and install its driver software if necessary. To the other side of the adapter, connect your device’s RS422 pins with cross-connection (Rx to Tx, Tx to Rx but positive to positive, negative to negative). You can find the hardware pins below. For ground connection, use the GND_DIGITAL pin. 

 

After proper connection, you should do pin multiplexing on your device to use Serial Port as RS422.


For JetPack-4.x

To do this, open new terminal then type these commands below.


sudo sh -c "echo 424 > /sys/class/gpio/export"
sudo sh -c "echo 436 > /sys/class/gpio/export"
sudo sh -c "echo out > /sys/class/gpio/gpio424/direction"
sudo sh -c "echo out > /sys/class/gpio/gpio436/direction"
sudo sh -c "echo 0 > /sys/class/gpio/gpio424/value"
sudo sh -c "echo 1 > /sys/class/gpio/gpio436/value"

For JetPack-5.x

Open a new terminal then type these commands below.


sudo sh -c "echo 443 > /sys/class/gpio/export"
sudo sh -c "echo 453 > /sys/class/gpio/export"
sudo sh -c "echo out > /sys/class/gpio/PR.00/direction"
sudo sh -c "echo out > /sys/class/gpio/PS.04/direction"
sudo sh -c "echo 0 > /sys/class/gpio/PR.00/value"
sudo sh -c "echo 1 > /sys/class/gpio/PS.04/value"


If you are using GtkTerm on Ubuntu, run these commands below. If you have done everything correctly you could see your keyboard presses on the other machine's serial terminal.

sudo gtkterm -p /dev/ttyTHS0 -s 115200


RS485 Test


To test RS485 functionality, we used a USB-Serial adapter. Connect that adapter to the USB port of the host PC and install its driver software if necessary. To the other side of the adapter, connect your device’s RS485 pins. You can find the hardware pins below. For ground connection, use the GND_DIGITAL pin. 


After proper connection, you should do pin multiplexing on your device to use Serial Port as RS485. 


For JetPack-4.x

To do this, open new terminal then type these commands below.


sudo sh -c "echo 267 > /sys/class/gpio/export"
sudo sh -c "echo 424 > /sys/class/gpio/export"
sudo sh -c "echo 436 > /sys/class/gpio/export"
sudo sh -c "echo out > /sys/class/gpio/gpio267/direction"
sudo sh -c "echo out > /sys/class/gpio/gpio424/direction"
sudo sh -c "echo out > /sys/class/gpio/gpio436/direction"
sudo sh -c "echo 1 > /sys/class/gpio/gpio424/value"
sudo sh -c "echo 1 > /sys/class/gpio/gpio436/value"


To Write Data:


sudo sh -c "echo 1 > /sys/class/gpio/gpio267/value"


To Read Data:


sudo sh -c "echo 0 > /sys/class/gpio/gpio267/value"

For JetPack-5.x

Open a new terminal then type these commands below.


sudo sh -c "echo 320 > /sys/class/gpio/export"
sudo sh -c "echo 443 > /sys/class/gpio/export"
sudo sh -c "echo 453 > /sys/class/gpio/export"
sudo sh -c "echo out > /sys/class/gpio/PCC.03/direction"
sudo sh -c "echo out > /sys/class/gpio/PR.00/direction"
sudo sh -c "echo out > /sys/class/gpio/PS.04/direction"
sudo sh -c "echo 1 > /sys/class/gpio/PR.00/value"
sudo sh -c "echo 1 > /sys/class/gpio/PS.04/value"


To Write Data:


sudo sh -c "echo 1 > /sys/class/gpio/PCC.03/value"


To Read Data:


sudo sh -c "echo 0 > /sys/class/gpio/PCC.03/value"


If you are using GtkTerm on Ubuntu, run these commands below. If you have done everything correctly you could see your keyboard presses on the other machine's serial terminal.


sudo gtkterm -p /dev/ttyTHS0 -s 115200 -w RS485

Thank you for reading our blog post.