Ameba Arduino: [RTL8710AF] UART – Communicate With The Computer Via UART

Introduction of UART

  • UART uses two wirelines, one for transmitting and the other one for receiving, so as to make the data transmission bidirectional. The commnication use a predefined frequency (baud rate) to transmit data.
  • However, Ameba is equipped with a number of hardware UART. But to be compatible with the Software Serial API of Arduino, Ameba follows the name “Software Serial”
    Ameba RTL8710 UART pin is different with Ameba RTL819A. RTL8710 does not have pins like the common UART D0(RX)/D1(TX) on RTL8195A, it uses D17(RX)/D5(TX).

Materials

  • #3 Ameba RTL8710 Board x 1
  • USB to TTL Adapter x 1

Example

In this example, we use UART to connect USB to TTL Adapter to Ameba.
USB to TTL Adapter sends data to Ameba, the data would be returned by Ameba, and showed on the screen.

  • Install USB to TTL Adapter

USB to TTL Adapter converts USB to Serial interface. Normally, there are 4 pins on the adapter, that is 3V3 (or 5V), GND, TX and RX. Gernerally, installing the driver for the USB to TTL Adapter would be required before using it. If the adapter uses the chip of FTDI, Windows would search and install the driver automatically, otherwise, you may need to install corresponding driver yorself.
Afterwards, open the Device Manager. You can find corresponding Serial Port of the USB to TTL Adapter:

5-1

  • Executing the Example


Open the “SoftwareSerialExample” example in “File” -> “Examples” -> “AmebaSoftwareSerial” -> “SoftwareSerialExample”:

5-2
Connect the wirelines as the diagram. The TX pin of USB to TTL Adapter is connected to D17 (which is its RX) of Ameba, and the RX pin of USB to TTL Adapter is connected to D5 (which is its TX) of Ameba.
 
5-3
 

Next, open the Serial Port Terminal, such as Putty, Tera Term. (We use Putty in this example.)Open the Putty window, choose “Serial” in Connection Type, and specify the port of USB to TTL Adapter in Serial line field (Ex. COM8).In Speed field, fill in the baud rate of this connection. (Note that both sides of the connection should use the same baud rate.) In this example we se baud rate 4800.
 
5-4

Next, click “Serial” on the left side. We set Data bits to 8, Stop bits to 1, Parity to None, and Flow control to None.
 
5-5

Then click Open, and press the reset button on Ameba. You can see the “Hello, world?” message appears in Putty. If insert characters in Putty, the input characters would be sent to Serial RX of Ameba by TX of USB to TTL Adapter, and returned by Serial TX of Ameba. Finally, RX of USB to TTL Adapter receives the returned characters and prints them in Putty. Therefore, if you insert “I am fine”, you would get something like this:

5-6

Code Reference

First, use SoftwareSerial: begin(speed) to set the baud rate for the serial communication:
https://www.arduino.cc/en/Reference/SoftwareSerialBegin

Use write() to send data, and use SoftwareSerial: available() to get the number of bytes available for reading from a software serial port:
https://www.arduino.cc/en/Reference/SoftwareSerialAvailable
If there are data available to read, use read() to read from serial port.
Please confirm that QQ communication software is installed