Ameba ARDUINO: Getting Started with AW-CU488 Thing Plus (RTL8721DM)

Introduction

Ameba is an easy-to-program platform for developing all kind of IoT applications. AW-CU488 Thing Plus is equipped with various peripheral interfaces, including WiFi, GPIO INT, I2C, UART, SPI, PWM, ADC. Through these interfaces, AW-CU488 Thing Plus can connect with electronic components such as LED, switches, manometer, hygrometer, PM2.5 dust sensors, …etc.
The collected data can be uploaded via WiFi and be utilized by applications on smart devices to realize IoT implementation.

AW-CU488 Thing Plus Board
get-start-1

AW-CU488 Thing Plus uses Type C USB to supply power, which is quite common in many smart devices. It also has an Auto Upload Circuit.
Please refer to the following figure and table for the pin diagram and functions.

AW-CU488 Thing Plus Pinmap
get-start-2

 GPIO pinGPIO INTADCPWMUARTSPII2CIRRGB LEDSWD
0PA18  SERIAL2_TXSPI_SCLK    
1PA16   SPI_MOSI    
2PA17   SPI_MISO    
3PA13 SERIAL1_RX (a)SPI1_MISO (b)    
4PA12 SERIAL1_TX (a)SPI1_MOSI (b)    
5PA26 SERIAL1_TX (b) I2C_SDA (a, qwiic)IR_RX (a)  
6PA25 SERIAL1_RX (b) I2C_SCL (a, qwiic)IR_TX (a)  
7PA30       
8PA19  SERIAL2_RXSPI_SS    
9PB3A6      SWD_CLK
10PB23    IR_TX (b)  
11PB22    IR_RX (b)  
12PB26        
13PB29     IR_RX (c)LED_BUILTIN (blue) 
14PB4A0 SPI1_MOSI (a)    
15PB5A1 SPI1_MISO (a)I2C_SCL (b)   
16PB6A2  SPI1_SCLK (a)I2C_SDA (b)   
17PB7A3 SPI1_SS (a)    
18PB1A4 SERIAL1_TX (c)     
19PB2A5 SERIAL1_RX (c)     
20PB31     IR_TX (c)  
21PA0        
22PA4        
23PA2        
24PA7  LOG_TX     
25PA8  LOG_RX     
26PA28       
27PA27       SWD_DATA
28PA15   SPI1_SS (b)    
29PA14   SPI1_SCLK (b)    

Set up developing environment

Step 1. OS environment

AW-CU488 Thing Plus (RTL8721DM) board currently supports Windows OS 32-bits or 64-bits, Linux OS (Ubuntu) and macOS. To have the best experiences, please use the latest version of OS.

For any Linux OS (Ubuntu) related issues, refer to https://forum.amebaiot.com/t/ubuntu-linux-environment/2259.

For any macOS related issues, refer to https://forum.amebaiot.com/t/macos-environment/2260.

Step 2. Set up Arduino IDE

From version 1.6.5, Arduino IDE supports third-party hardware. Arduino IDE is used to develop applications on the board, and the Arduino basic examples.

Arduino IDE can be downloaded in the Arduino Website: https://www.arduino.cc/en/Main/Software.
When the installation is finished, open Arduino IDE. Go to “File” → “Preferences”.

Paste the following URL into the “Additional Boards Manager URLs” field:
https://github.com/ambiot/ambd_arduino/raw/master/Arduino_package/package_realtek_amebad_index.json

Next, go to “Tools” → “Boards” → “Boards Manager”:

get-start-3

The “Boards Manager” requires several seconds to refresh all hardware files (if the network is in bad condition, it may take longer). Search “Realtek” and find “Realtek Ameba Boards (32-bits ARM Cortex-M33 @ 200MHz)” in the list, click “Install”, then the Arduino IDE starts to download required files for AmebaD family including AW-CU488 Thing Plus.

get-start-4

If there is downloading issue (bad internet or no GitHub access), please refer to the following link at “Download/Software Development Kit”. There are 3 sections.

1. “AmebaD_Arduino_patch1_SDK”, please select at least 1 of the SDKs. There are 5 latest released SDK options.
2. “AmebaD_Arduino_patch2_Tools”, please select according to operating system. There are Windows, Linux and macOS.
3. “AmebaD_Arduino_Source_Code”, this section is optional. Download it for the latest source code.

Download the files selected, then unzip (patch 1 and patch 2 are compulsory). There are “Install.doc”/”Install.pdf” for you to refer to installation steps. According to your system, please run the installation tool in the “Offline_SDK_installation_tool” folder.
After the installation, select AmebaD as current connected board in “Tools” → “Board” →“Ameba ARM (32-bits) Boards” → “AW-CU488 Thing Plus (RTL8721DM)”:

get-start-5

Step 3. Install the Serial Port

First, connect the board to computer via Type C USB:

AW-CU488 Thing Plus
get-start-6

After connected, the USB driver will be automatically installed. If there is any driver issue of connecting board, please go to https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers?tab=downloads for the USB driver. Check the COM Port number in the Device Manager for Windows OS user:

get-start-7

Go to “Tools” → “Port” and select the correct COM port.

get-start-8

Go to “Tools” → “Serial Monitor”, set the baud rate as “115200”, and press the RST button to check the serial port connection.

get-start-9

Try the First Example

Step 1. Compile & Upload

Arduino IDE provides many built-in examples, which can be compiled, uploaded, and run directly on the boards. Here, we take the “Blink” example as the first try.
Open “File” → “Examples” → “01. Basics” → “Blink”:

get-start-10

get-start-11

There are onboard LED on AW-CU488 Thing Plus, the default “LED_BUILTIN” is blue.
Next, we compile the sample code directly; click “Sketch” → “Verify/Compile”.

get-start-12

Arduino IDE prints the compiling message in the bottom area of the IDE window. When the compilation is finished, you will get the message as following.

get-start-13

Afterwards, we will upload the compiled code to board.
Remember to enable the Auto Upload Mode. In “Tools” → “Auto Upload Mode” → “Enable / Disable”.

get-start-14

Please make sure the board is connected to your computer, then click “Sketch” → “Upload”
Successful Upload will be shown with a message “All images are sent successfully!”

get-start-15

Step 2.Run the Blink example

The board will be reset automatically, and the onboard LED will start blinking.
In each example, Arduino not only provides sample code but also detailed documentation, including wiring diagram, sample code explanation, technical details, etc. These examples can be directly used on AW-CU488 Thing Plus. Refer to detailed information of the Blink example in the link below:

https://www.arduino.cc/en/Tutorial/BuiltInExamples/Blink

If you encounter any problem, please refer to Q&A.

Tool Feature

Erase Flash

get-start-17

• Enable: erase the image in the flash memory without uploading the current image.
• Disable: upload the user code upon compilation is finished.

“Erase Flash” is default selected as “Disable” to upload the user code.

Standard Lib Enable

get-start-17

• Arduino_STD_PRTINF: enable the usage of Arduino avr “stdio.h” and “#include ” when using printf
• NA: printf() is using based on standard sdk _rtl_printf()

“Standard Lib Enable” is default selected as “NA”.

Upload Speed

get-start-17

Selection of uploading baud rate at 1,500,000 or 921,600.

Please confirm that QQ communication software is installed