We say that this board has an Arduino form factor because it has the same pin headers as the Arduino Uno board and we can use shields for the Arduino.
Other boards may need an external USB flash programming device and dupont wire connections. This board already contains its own on-board flash programmer. See end of project for Windows driver advice.
IO Pin HeadersYes, the Arduino Header does match the Arduino Uno board form factor. Morpho headers are a similar pinout format for STM-32 boards. You may use Arduino shields with this board carefully. Check code and wiring: I2C, SPI, UART pins may be different.
Follow the labels to see the match up in pinouts. The inner row of Morpho pins are the same as the Arduino pins and connect to the same IO on the processor chip. In another project we will program this board with the Arduino IDE program. These IO pins will become PA_0, PA_1, etc. in our sketches.
Connect LED1 and LED2The board has two built-in LED lamps. We need to manually connect these lamps to our IO pins with dupont connector wires.
Connect LED1 to PA0 pin of the Arduino header. Connect LED2 to PA0 pin of the Morpho header. Make sure you connect to the outside row of the Morpho header.
Open EmbeetleDownload and unzip Embeetle IDE studio for Windows or Linux. It is a program that we can run from the folder by clicking on the icon.
Click CREATE Generate project. Embeetle will refresh the list of available projects.
You can select from a database of sample software. WCH products are at the end. The default location for this code download is your home folder.
We want to filter for the CH32V103 and there is a single demo program we can download. It will be the GPIO example to toggle PortApin 0.
We will have to find and open our source code. Embeetle default opening page.
Use the Filetree panel to navigate through the source files. In Samples look for GPIO.
Inside GPIO_Toggle folder we see the input source files for our project. Double click on main.c to see our input program.
There are a lot of source code files that are not included in our project. Green files are included, red are not. Right-click on the root folder and select Force include to start a scan.
A progress bar at the bottom will show file checking by the program. The other source folders can be run as demo programs.
GPIO_ToggleDouble click on main.c to see the program we will run. We've seen this same program configured for other processors. This time it toggles pin0 of GPIO PORTA. Change both the init function and main function to select another pin.
Click the build icon in the menu bar. A new window opens scrolling output text messages. Check the messages to make sure you have a successful compilation of an elf file that has a meaningful size.
Embeetle has generated three output files that can be loaded into our processor to run. Embeetle uses a program called OpenOCD to upload our elf file. The default location is your home folder.
Click on the flash icon in the toolbar. The output panel scrolls the upload progress. Read through the messages. They should name a WCH-Link programming circuit. Linux may require you to install the openocd software package.
Built-in LED1 and LED2 will blink at the rate selected in main.c.
If you want to change the GPIO pin that is toggled you have to modify both an INIT function and the main function. The delay value is in milliseconds.
This is a computer language called C. Arduino sketches are written in a language called C++ (see plus plus). They are both similar and different and we can move code from one to the other.
There are Errors!Those are warnings. The compiler just has to use a variable in one data type as an equivalent value using casting. Don't worry about it, the code runs.
Your Windows computer needs a driver to talk to the board through its LinkUtility flash programming circuit. If you are unable to upload your compiled program to your board then check the Device Manager to see if your PC knows what to do with the device.
Zadig is one way of installing a usable driver. Project Flash RISC-V Chips shows how to install a driver with the WCH-LinkUtility program.
We want to see it in the COM port list. The com port number will work for both flash programming and UART serial interface.
WCH-LinkUtility allows us to upload and download the flash program in the processor.
Comments
Please log in or sign up to comment.