Section D.2 Creating Your TemplateProject
These instructions assume that you have followed all of the installation instructions in SectionΒ D.1. In particular, they assume that you have created the folder structure shown there and that you have selected the
workspace folder inside your ES28 directory as your STM32CubeIDE workspace. If you have not yet succeeded with these steps, please stop right here and ask for help.
The steps below walk you through creating a
TemplateProject from which weβll derive all of our other ENGS 28 projects this term. While the creation of this template project is cumbersome, itβll make creating future projects much easier.
-
Open STM32CubeIDE. On the welcome screen, click Create / Import STM32 project.

Figure D.2.1. The STM32CubeIDE welcome screen. The Create / Import STM32 project button under Start a project is circled. -
In the popup window, select STM32CubeIDE Empty Project under Create New STM32 Project. Click Next.

Figure D.2.2. The Create / Import STM32 Project window with STM32CubeIDE Empty Project selected. -
Switch to the Board Selector tab and select the NUCLEO-C031C6. Click Next.

Figure D.2.3. The Board Selector tab, circled. Once a board is selected, its name appears beside Selected device. 
Figure D.2.4. Part of the board list with the NUCLEO-C031C6 row selected and boxed. Its microcontroller, the STM32C031C6, is listed beside it in the Reference column. -
Enter
TemplateProjectfor the Project Name and accept all selected options (C for the targeted language, Executable for the targeted binary type). Click Finish.
Figure D.2.5. The project setup page. On your computer the Location field shows the path to the workspacefolder inside yourES28folder; it is blanked out here. -
The IDE opens with a set of folders pre-created, among them
Inc,SrcandStartup. -
Inside
Src, deletemain.cand keep the remaining files,syscalls.candsysmem.c. We deletemain.cbecause every program youβll add to a copy of this project has its ownmain()function, and a project can have only onemain()function. -
Right-click on
TemplateProjectand select Properties. In the window that opens, expand the C/C++ General menu item on the left and click on Paths and Symbols. -
Select the Source Location tab and click Link Folder⦠on the right. The screenshot below was taken after the next three steps, so its list already includes
/TemplateProject/Library; on your screen the list shows onlyInc,SrcandStartupat this point.
Figure D.2.6. The Source Location tab of Paths and Symbols, with Link Folder⦠circled. -
In the popup, check the Link to folder in the file system box, then select Browse. The red Folder name must be specified message clears once Browse fills in the folder.

Figure D.2.7. The New Folder popup with Link to folder in the file system checked. -
Navigate to your
ES28folder, and inside it selectLibrary, then click Open. On Windows this button says Select Folder.
Figure D.2.8. Selecting Libraryas the link target on a Mac. -
Click OK in the remaining window, then Apply and Close in the Properties for TemplateProject window.
-
In the Project Explorer on the left of your IDE, expand the
Libraryfolder and inside it thechipheadersfolder. You should be able to seeDeviceandInclude, and, besidechipheaders,mylib.
Figure D.2.9. TemplateProjectin the Project Explorer with the linkedLibraryfolder expanded.DeviceandIncludeare insidechipheaders;mylibholdsES28.handsysinit.c. -
For each of these three folders, right-click the folder, select Add/remove include pathβ¦, keep the defaults, and click OK.

Figure D.2.10. The context menu of a folder in Library, with Add/remove include path⦠circled. The dashed line marks where the middle of the menu has been cut out of the screenshot.
Figure D.2.11. The popup that follows Add/remove include pathβ¦, with both configurations, Debug and Release, checked by default. -
Right-click (again!) on
TemplateProjectin the Project Explorer and select Properties. As before, expand the C/C++ General menu and select Paths and Symbols. -
Select the Symbols tab and click Add.

Figure D.2.12. The Symbols tab of Paths and Symbols, before the new symbol is added. -
In the Name field of the popup, enter
STM32C031xx(be sure to get this exactly right, including upper and lower case) and click OK. The chip headerstm32c0xx.his written for the whole STM32C0 family. This symbol selects which member of the family we use, so that the header includes the register definitions for the STM32C031C6.
Figure D.2.13. The Add symbol popup with STM32C031xxentered as the name. -
Make sure what you see is this list:

Figure D.2.14. The finished symbol list: DEBUG,NUCLEO_C031C6,STM32,STM32C0,STM32C031C6TxandSTM32C031xx. -
Click Apply and Close, saying yes to the question about rebuilding the index.
What you just created is our
TemplateProject for the entire term. Each time we start a new project weβll simply make a copy of this TemplateProject so that we wonβt have to do any of the above steps again.
