Microcontroller Embedded C Programming Lecture 12| Creating a project for the HOST

  • Post author:
  • Post category:Blog

 

Creating a project for the HOST

 

 

 

In this article, let me show you how to create a project using STM32CubeIDE. 

Sometimes, you will be creating a project for our host. That means the project is going to run on our host machine. In my case, the host machine is X86 64 bit machine.

And sometimes, we are going to create a project for our target, and the target in our case is the STM32 microcontroller based Discovery board.

Figure 1. Host and Target
Figure 1. Host and Target

 

Let’s first learn how to create a project for the host. 

Creating a Project for the HOST:

First, launch the STM32CubeIDE. The same IDE you will use, and here we will open the workspace we created for our host. Paste the My_workspace/host directory path and click on Launch.

Figure 2. Select a directory as workspace
Figure 2. Select a directory as workspace

 

Go to File, go to New, and click on the C/C++ Project.

Figure 3. Creating a new project for the HOST
Figure 3. Creating a new project for the HOST

 

And click on C Managed Build here, and then click Next.

Figure 4. Templates for New C/C++ Project
Figure 4. Templates for New C/C++ Project

 

Then you can give the project name. Let me name it as 000TestProject. Select MinGW GCC, and Click Next.

If you create the project under a windows machine, you select MinGW GCC. Do not select MCU ARM or Cross GCC. Why? Because we are writing the application for our host.

Figure 5. Create a C Project for Windows
Figure 5. Create a C Project for Windows

 

If you are using Linux/MAC just select GCC, as shown in Figure 6.

Figure 6. Creating a C Project for Linux/MAC
Figure 6. Creating a C Project for Linux/MAC

 

And after that, you can click Finish.

Figure 7. Select Configurations
Figure 7. Select Configurations

 

We can see that 000TestProject is created (Figure 8).

Figure 8. 000TestProject is Created.
Figure 8. 000TestProject is Created.

 

Let’s add a source file. For that, right-click on the project → New→  Source File.

Figure 9. Adding a source file
Figure 9. Adding a source file

 

Now add a source file. Let me call it main.c. So, this is a source file where I will write my ‘C’ program. 

Figure 10. Add a source file
Figure 10. Add a source file

 

We created a main.c file, as shown in Figure 11. And here we are going to write the code.

Creating a project for the HOST using STM32CubeIDE
Figure 11. main.c file

 

Let me quickly add some code. Now I just added a small code snippet into the source file main.c, shown in Figure 12. You need not understand this code anyway. I just added some code to show you how to build and test the code.

Creating a project for the HOST using STM32CubeIDE
Figure 12. Small code snippet

 

Once you write your code into the source file, what you have to do is, you have to build the project. For that, right-click on the project and then select build project.

Creating a project for the HOST using STM32CubeIDE
Figure 13. Build project

And then, check the console window; it will show you all the build logs.

 

For example, let me do it once again. Let me build the project, and here we can see in the console that the project is build successfully and the 000TestProject.exe file is created. ‘exe’ means that it is executable. You can also see this 000TestProject.exe file under Binaries. You can execute this file. 

Creating a project for the HOST using STM32CubeIDE
Figure 14. Build the project once again

 

For that, you have to go to this 000TestProject.exe file path. Right-click on this exe file, and select properties, as shown in Figure 15. 

Creating a project for the HOST using STM32CubeIDE
Figure 15. Go to exe file path

 

And then click on the Show In System Explorer icon here. 

Creating a project for the HOST using STM32CubeIDE
Figure 16. Properties for 000TestProject.exe

 

So, which will open the folder where that exe file is present. The exe is present here( See Figure 17).

Creating a project for the HOST using STM32CubeIDE
Figure 17. 000TestProject path

 

Launch that as a windows command prompt application.

Creating a project for the HOST using STM32CubeIDE
Figure 18. 000TestProject.exe file Command prompt

 

That’s how you build and test the code by using the STM32CubeIDE for the host. In the following article, let’s learn how to create a project for the target board. 

 

FastBit Embedded Brain Academy Courses

Click here: https://fastbitlab.com/course1

 

FastBitLab

The FastBit Embedded Brain Academy uses the power of internet to bring the online courses related to the field of embedded system programming, Real time operating system, Embedded Linux systems, etc at your finger tip with very low cost. Backed with strong experience of industry, we have produced lots of courses with the customer enrolment over 3000+ across 100+ countries.

Leave a Reply