RISC-V MCU CH32V307 Tutorial — Voice Control DEMO


Configuration of the Development Environment
DEMO Programme Procedure Description

Configuration of the Development Environment

The Installment and Configuration of RT-Thread Studio

  1. Access to the download page on the official website of RT-Thread to download the installation package of RT-Thread Studio at the bottom of the page.

  2. After the download is complete, double click RT-Thread Studio-v2.1.3-setup-x86_64_20211118-1000 to install it.

  3. After the installation is complete, register or log in to enter RT-Thread Studio.

  4. As the current tool of RT-Thread Studio for V307 is old, the location of the tool chain of RT-Thread Studio should be modified to the gcc tool chain in the installation directory of MRS.

    Step 1: Import voice control DEMO in RT-Thread Studio, and click File -> Import in the interface of RT-Thread Studio.

    Step 2: Select RT-Thread Studio project to workspace and click Next.

    Step 3: Select the folder of voice control DEMO that has been downloaded and unzipped, and click Finish to complete the import of the project.

    Note: Chinese are not allowed in the catalogue.

    Close the welcome screen to see the project explorer of Voice Control DEMO.

    Step 4: Right-click the project CH32V307_RTT_VC_RC and select Properties.

    Step 5: Click MCU -> RISC-V Toolchains Paths -> Browse to add the gcc tool chain in your computer's MRS installation directory as RT-Thread Studio tool chain.

    Note: For the installation of MRS, please refer to the CH32V307 tutorial [Development Environment].

Exporting RISC-V programming tools under WCH-Link

Since RT-Thread Studio does not integrate the V307 online debugging interface, you need to use the tools under MRS to download the program. MRS supports exporting the RISC-V programming tools under WCH-Link, and you can use the tools to download the program for V307 after exporting.

Open MRS software, click `Tools -> Export WCH-Link RISC-V MCU burn-in tool and select the save directory to export.

Unzip the WCH-Link RISC-V MCU download tool and double click to open it.

Note: For this DEMO program, it is better not to check the erase all. The last template of the chip Flash is used to store the voice feature vector, just erase it by page. If you encounter unsuccessful download, you can repeat it several times (the problem can be solved when the debugger program is unified and upgraded).

DEMO Programme Procedure Description


The program is composed of four parts: audio sampling thread, recognition thread, template training thread, LCD display thread, in which recognition thread and template training thread cannot run at the same time.

The ADC take analog voltage of PA1 port as sample. After the sampling is completed, the recognition thread is notified through an interrupt, and the recognition thread calculates the recognition result and transmits it to the LCD display. When the development board receives the practice command from the serial port, it will run the template training thread. After it starts running, it will follow the serial port to output information for training and store it in the template library. Each keyword can correspond to multiple templates, the number of templates can be defined by the macro in the header file, and the default value is 2.

After the recognition mode starts to run, the content on the LCD screen is divided into three areas, namely the Logo area, the small red block moving area, and the recognition prompt area. You can modify the layout and logo at will. The default logo size is 80*60. When the recognition prompt area shows blue "speaking", you can say "up", "down", "left" or "right" to the microphone. If the recognition is successful, the prompt area will display the red "stop" and the current recognition result "result:xxx", and the small red block on the screen will also move in the corresponding direction.

Operation Procedure

Step 1: Connect the development board and use the WCH-Link RISC-V MCU download tool exported above to download the compiled voice control DEMO into the development board. The compiled voice control DEMO program is in the RT-Thread Studio project file Debug directory.

Step 2: Get into PuTTY the latest release on its official site to download putty tool for serial connection. After completing, double-click to open and then click Serial. Set the certain connect port for development board (you can open the device manager after successfully connecting the development board for confirming the connect port), as well as setting the baud rate-115200. Lastly, click open to open the serial terminal.

Step 3: After entering the terminal, click the RST button on the board to reset the development board. If shows the picture below, it means that the voice control DEMO has been successfully downloaded into the development board.

Note. If there is no display on the terminal, check whether the jumper cap is correctly connected.

You can enter help in the terminal to view executable commands, or you can enter practice to start voice training.

Step 4: Enter practice in the terminal to start the voice training work. By following the prompts in the terminal, you can complete the voice training process.

Step 5: When the blue "speaking" shows on the screen, you can say "up", "down", "left" or "right" to the microphone. If the recognition is successful, the screen will display red "stop" and the current recognition result "result:xxx". Meanwhile, the small red block on the screen will also move in the corresponding direction.

Leave a Reply

Your email address will not be published. Required fields are marked *