# RTL8722DM-操作手冊 ## 參考資料 * [Ameba官網使用設定](https://www.amebaiot.com/zh/amebad-arduino-getting-started/) ## 設備需求 AmebaD RTL8722CSM/RTL8722DM 可於燒錄於 Windows XP/7/8/10 32-bits/64-bits, Linux 和 Mac. 建議可使用 Arduino IDE(1.8.12)或更新的版本進行程式撰寫與燒錄. ``` ``` ## 簡介 AmebaD RTL8722CSM/RTL8722DM Ameba是易於開發現今物聯網應用的可程式化控制板,具多組通訊介面,包含Wifi, Bluetooth, GPIO, I2C, UART, SPI, PWM, ADC. 也可以連接一般Arduino系列模組,如LED,開關,各類感測器等。 並可透過Wifi, Bluetooth傳輸串聯各類物聯網裝置與整合性應用。 ![MB picture](https://i.imgur.com/8f7IXfS.jpg) AmebaD and Arduino Uno have similar size, as shown in the above figure, and the pins on AmebaD are compatible with Arduino Uno. AmebaD uses Micro USB to supply power, which is common in many smart devices. Please refer to the following figure and table for the pin diagram and function of AmebaD. ![](https://i.imgur.com/Fa8Di5R.png) | | PIN name | GPIO INT | ADC | PWM | UART | SPI | I2C | | --- | -------- | -------- | ---- | ----- | ------------- | --------- | -------- | | D00 | GPIOB_2 | ✓ | ADC5 | | | | | | D01 | GPIOB_1 | ✓ | ADC4 | | | | | | D02 | GPIOB_3 | ✓ | ADC6 | | | | | | D03 | GPIOB_31 | ✓ | | | | | | | D04 | GPIOB_30 | ✓ | | | | | | | D05 | GPIOB_28 | ✓ | | | | | | | D06 | GPIOB_29 | ✓ | | | | | | | D07 | NC | | | | | | | | D08 | GPIOB_22 | ✓ | | PWM14 | | | | | D09 | GPIOB_23 | ✓ | | PWM15 | | | | | D10 | GPIOB_21 | ✓ | | PWM13 | UART0_RTS(b) | SPI0_CS | | | D11 | GPIOB_18 | ✓ | | PWM10 | UART0_RX(b) | SPI0_MOSI | | | D12 | GPIOB_19 | ✓ | | PWM11 | UART0_TX(b) | SPI0_MISO | | | D13 | GPIOB_20 | ✓ | | PWM12 | UART0_CTS(b) | SPI0_CLK | | | D14 | GPIOA_7 | ✓ | | | UART2_TX(log) | | | | D15 | GPIOA_8 | ✓ | | | UART2_RX(log) | | | | D16 | GPIOA_25 | ✓ | | PWM4 | UART3_RX(a) | | I2C0_SCL | | D17 | GPIOA_26 | ✓ | | PWM5 | UART3_TX(a) | | I2C0_SDA | | D18 | GPIOB_7 | ✓ | ADC3 | PWM17 | | SPI1_CS | | | D19 | GPIOB_6 | ✓ | ADC2 | | | SPI1_CLK | | | D20 | GPIOB_5 | ✓ | ADC1 | PWM9 | | SPI1_MISO | | | D21 | GPIOB_4 | ✓ | ADC0 | PWM8 | | SPI1_MOSI | | | D22 | GPIOA_28 | ✓ | | | | | | | D23 | GPIOA_24 | ✓ | | PWM3 | UART0_CTS(a) | | I2C1_SDA | | D24 | GPIOA_23 | ✓ | | PWM2 | UART0_RTS(a) | | I2C1_SCL | | D25 | GPIOA_22 | ✓ | | | UART0_RX(a) | | | | D26 | GPIOA_21 | ✓ | | | UART0_TX(a) | | | | D27 | GPIOA_20 | ✓ | | | | | | | D28 | GPIOA_19 | ✓ | | | | | | ![](https://i.imgur.com/dI4TkZw.png) ``` ``` ## Setting up Development Environment ### Step 1. Installing the Driver First, connect AmebaD to the computer via Micro USB: ![](https://i.imgur.com/CnmcmjT.jpg) If this is the first time you connect AmebaD to your computer, the USB driver for AmebaD will be automatic installed. You can check the COM port number in Device Manager of your computer: ![](https://i.imgur.com/cAW0NTs.png) ``` ``` ### Step 2. Set up Arduino IDE From version 1.6.5, Arduino IDE supports third-party hardware. Therefore, we can use Arduino IDE to develop applications on AmebaD, and the examples of Arduino can run on AmebaD too. Arduino IDE can be downloaded in the Arduino website: https://www.arduino.cc/en/Main/Software When the installation is finished, open Arduino IDE. To set up AmebaD correctly in Arduino IDE, go to “File” -> “Preferences” ![](https://i.imgur.com/98wA5ZU.png) And paste the following URL into “Additional Boards Manager URLs” field: https://github.com/ambiot/ambd_arduino/raw/master/Arduino_package/package_realtek.com_amebad_index.json Next, go to “Tools” -> “Board” -> “Boards Manager”: ![](https://i.imgur.com/0x9a7aO.png) The “Boards Manager” requires about 10~20 seconds to refresh all hardware files (if the network is in bad condition, it may take longer). Every time the new hardware is connected, we need to reopen the Board Manager. So, we close the Boards Manager, and then open it again. Find “Realtek AmebaD Boards” in the list, click “Install”, then the Arduino IDE starts to download required files for AmebaD. ![](https://i.imgur.com/bCyRtix.png) Finally, we select AmebaD as current connected board in “tools” -> “Board” -> “Arduino AmebaD”: ![](https://i.imgur.com/KaV8svZ.png) ``` ``` ``` ``` ## 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”: ![](https://i.imgur.com/qx8KXcv.png) Arduino IDE opens a new window with the complete sample code. ![](https://i.imgur.com/xhpPAkP.png) Next, we compile the sample code directly; click “Sketch” -> “Verify/Compile” ![](https://i.imgur.com/EHdMppx.png) Arduino IDE prints the compiling messages in the bottom area of the IDE window. When the compilation is finished, you will get the message similar to the following figure: ![](https://i.imgur.com/lK74zeF.png) Afterwards, we will upload the compiled code to AmebaD. Please make sure AmebaD is connected to your computer, then click “Sketch” -> “Upload”. The Arduino IDE will compile first then upload. During the uploading process, users are required to enter the upload mode of the board. Arduino IDE will wait 5s for DEV board to enter the upload mode. ![](https://i.imgur.com/TtbH6mL.png) ### 燒錄步驟 * 看到 pleas就要按下並按住 UART_DOWNLOAD button * 並加按RESET button一下即可放開RESET button 持續按住UART_DOWNLOAD button * 直到出現如下圖 即可放開 完成後要再按一下RESET button 讓code loading並執行出來 ![](https://i.imgur.com/fwb3EsF.png) * 若使用arduino 範例程式腳位定義 就依照Arduino D13 在數位輸出需這樣寫digitalWrite(13, HIGH) (不是晶片的GPIOB_x) To enter the upload mode, first press and hold the UART_DOWNLOAD button, then press the RESET button. If success, you should see a green LED flashing on the DEV board. ![](https://i.imgur.com/U1rSoOy.jpg) Again, during the uploading procedure the IDE prints messages. Uploading procedure takes considerably longer time (about 30 seconds to 1 minute). When upload completed, the “Done uploading” message is printed. ![](https://i.imgur.com/xlPPq7L.png) ``` ``` ### Step 2.Run the Blink example 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 AmebaD. So, we find the detailed information of the Blink example: https://www.arduino.cc/en/Tutorial/Blink In short, this example makes LED blinks, and it uses GPIO pin 08 (refer to the pin diagram D08). Then we connect the LED and resistance as the following figure: (NOTE: In an LED, the longer pin is the positive pole, and shorter pin is the negative pole. So we connect the longer pin to D08, and connect the shorter pin to GND. In addition, please use a resister with suitable resistance in series between LED and GND to protect LED) ![](https://i.imgur.com/IwG4zgM.png) Finally, press the RESET button, and you can see the LED blinking. If you encounter any problem, please refer to Trouble-shooting.