This laboratory project acts as the crucial step into firmware programming in to the BCA 143 Subject. Using the STM32F407ZGT6 microcontroller with the RT-Thread RT-Spark development board. Laboratory 0 demonstrates the installation of applications such as STM32CubeIDE, STM32CubeMX, and Git, setting up and making of accounts in GitHub and Hackster.io, configuration of Input/Output (GPIO) pins, and creating an LED blink project using the RT-Spark STM32F407ZGT6 development board using STM32CubeMX and STM32CubeIDE. With the RT-Spark board, a code was programmed to toggle the onboard LED and set a toggle delay at a an interval. For this project, it has version control via GitHub and the publication of the project documentation in Hackster.io.
Hardware DescriptionThe main component used is the RT-Thread RT-Spark Development Board, with high performance STM32F407ZGT6 microcontroller (ARM Cortex-M4).
For visual representation, the on-board LEDs are being used. Based on the board schematics and pin definition:
- Blue LED: Connected to pin PF11
- Red LED: Connected to pin PF12
The circuit design is dependent on the GPIO pins being configured as outputs. The microcontroller sets these pins to a logic high (1) or low state (0), current flows through LED making it light up.
Required Materials
Hardware:
- RT-Thread RT-Spark Board
- USB Type-C Cable
- Windows PC
Software:
- STM32CubeIDE
- STM32CubeMX
- Git
- GitHub.com
- Hackster.io
The approach is divided into five phases, STM32CubeIDE & CubeMX setup, creating STM32 Blink project, building and debugging RT-Spark, creating GitHub and Hackster.io account.
Step 1: Install All Required Software1.1 Install STM32CubeIDE on Windows
- Go open a browser and search STMicroelectronics STM32CubeIDE page and click the download link for Windows only.
- Right-click the installer, choose Run as administrator, and accept all and default folder settings to finish the installation, if Windows asks to allow this app to make changes, click Yes.
- Launch and open STM32CubeIDE, accept the default workspace folder, and click launch to start.
If you have problems on following the process you may check the link provided:
1.2 Install STM32CubeMX on Windows
- Open a browser, go to ST’s STM32CubeMX page, and click the download link for Windows only.
- Right-click the downloaded installer, choose Run as administrator, and proceed with the default setting, accept the license and install in the default folder.
- Click Finish to open STM32CubeMX and accept the default workspace folder, and click launch to start to confirm the application starts.
Check this video if you want to have a guide video in installing STM32CubeMX:
Step 2: Create the STM32 Blink ProjectThe RT-Spark Development Board is equipped with STM32F407ZGT6 Microcontroller. Figure 1 shows the board features, the on-board LED connected to a GPIO pin.
2.1 Create a new STM32 Project
- In STM32CubeMX, click File → New → STM32 Project. In MCU/MPU Filters under look for the Commercial Part Number and search for and select the STM32F407ZGT6 chip to match the RT-Spark board, then click Start Project.
- In the Pinout tab, locate pins PF11 and PF12 (as shown in Figure 1) click and set both to GPIO_Output to control the LEDs.
- Go to the Project Manager tab. Enter the Project Name (e.g., Last_Name_STM32_Blink_LED), choose the Project Location, and make sure the Toolchain/IDE is selected to STM32CubeIDE.
- Click generate code to automatically create the project files. Once complete, click Open Project to automatically launch STM32CubeIDE with the new project ready.
Optional: If you want to see the microcontroller pinout view and it's configuration tabs (Pinout & Configuration, Clock Configuration, etc.), open the .ioc file in the generated project.
2.2 Write a simple LED Blink Program
- Once STM32CubeIDE project file is created, look for the project explorer and click your project that is automatically created earlier, to make sure the project file is error free, find the hammer icon and click → Build All.
It should display like this in the terminal:
- If you already expand your project, go to and expand Core → Src, find and double-click the main.c fil
Below is the typical code structure recommended in ST’s blink tutorials, simply adapt only the pin names to match the specific configuration:
In the main.c file find the infinite loop inside int main(void):
- Replace the pin names with the actual names in the configuration in the board (e.g., GPIOF, GPIO_PIN_11, and GPIO_PIN_12).
- Check if the #include "main.h" is found above, if not add that. But typically it's there,
- The loop will toggle the LED every 500ms, a visible blink can be seen, try increasing the toggle delay , values between 1000ms and 10000ms, notice the difference of changing the delay.
- Connect the RT-Spark board to your windows pc using USB Cable to Type C, the cable should be connected to the debug label in the board and install all drivers needed.
- In the STM32CubeIDE, click build ( hammer icon) to build the project.
- Once the build proceeds without errors click the green bug icon to Debug or the green play icon to Run.
- When debug configuration dialog appears, accept the default ST-Link configuration and click OK to proceed.
- STM32CubeIDE will program the board, after it finishes, check if the code's running, and click Resume if debug mode is selected.
You can see the RT-Spark board LED is blinking at specified toggle delay time set.
Step 4: Upload your project to GitHub(If you already have an account skip this step in creating an GitHub account).
4.1 Create GitHub account
- Open a browser and go to github.com
- Sign Up to GitHub
- Use your institute email, remember your username and password you used in creating the account, follow other instructions to complete your creation of your account.
- Choose the free plan for now, and skip surveys.
You can also check the Youtube Link provided:
You have now your GitHub account logged in to the website.
4.2 Create your new GitHub repository
- Now go the the dashboard, and click new to create a new repository.
- Enter a Repository Name
- Set to Public
- Do not add a README, .gitignore, or license, then click create repository.
4.3 Install Git for windows
- Download the Git for Windows Setup
- In the downloads folder find the installer file and install Git, and click finish.
- Once installed you are ready to use from Git Bash or Command Prompt
If you have problems in installing you may follow the Youtube link provided:
4.4 Upload your STM32CubeIDE project using Git
- Go to File Explorer and locate your STM32 Project folder containing all the files required for this project and proceed to the folder.
- In your address bar type cmd.
- After typing cmd, click enter
- In the Command prompt, enter the following commands one by one, by pressing Enter one after the other.
git init
git add .
git commit -m "Initial commit: STM32F407ZGT6 Blink LED"Link your local project to the GitHub Repository, and replace it with your own URL.
- Type and enter these commands one after the other:
git remote add origin https://github.com/yourname/rt-spark-blink-led.git
git branch -M main
git push -u origin main- If you are asked for authentication, enter the credentials to you GitHub account to complete the process, a separate window may open for you to authorize.
Refresh your GitHub repository page, and check if all files are successfully and uploaded visible online.
Step 5: Create a Hackster.io account- You may use your GitHub account to create an account to make it easier.
5.1 Create a Hackter.io project
Presenting your project to the fellow innovators or developers is good for you to display what you made and easily document and share your hardware projects online.
- In your dashboard find create project
- After creating project, create a short title, elevator pitch, and add a cover image for your project and click continue.
- Now finish your project by completing the checklist, basics, team, things, story, and attachments.
Save your project and you are done with your project and it is shared online.
DocumentationThe infinite loop used used in the program, setting the toggle delay to specific interval.
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
HAL_GPIO_TogglePin(GPIOF, GPIO_PIN_11);
HAL_GPIO_TogglePin(GPIOF, GPIO_PIN_12);
HAL_Delay(500);
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */ The project is built using the STM32CubeIDE and CubeMX integration. The RT-Spark is connected to the PC via USB Type C cable to supply power to the board enabling the ST-Link debugging configuration.
Result:
Following this, the toolchain used is correctly installed including the drivers and the GPIO configuration is accurate.. Your blinking led project will work.
ConclusionFor Lab 0, learning is the first step of the embedded journey. Installing STM32CubeIDE, STM32CubeMX, and Git, moving to configuring these new apps, and then creating a simple LED blink project using the RT-Thread RT-Spark development board with ST's applications was a great milestone to achieve because it was not easy as a beginner.
This include creating a GitHub account and Hackster.io profile, and lastly, creating a repository and a project to showcase, which was not an easy task. Creating the title, elevator pitch, and the story was the difficult part for me, but facing these challenges made me think critically and plan for greater heights. I am loving these kinds of things and hoping to learn more in this subject.





Comments