Skip to main content

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.
  1. Open STM32CubeIDE. On the welcome screen, click Create / Import STM32 project.
    STM32CubeIDE welcome screen with the Create / Import STM32 project button circled in red.
    Figure D.2.1. The STM32CubeIDE welcome screen. The Create / Import STM32 project button under Start a project is circled.
  2. In the popup window, select STM32CubeIDE Empty Project under Create New STM32 Project. Click Next.
    Create / Import STM32 Project window, STM32CubeIDE Empty Project boxed and the Next button circled.
    Figure D.2.2. The Create / Import STM32 Project window with STM32CubeIDE Empty Project selected.
  3. Switch to the Board Selector tab and select the NUCLEO-C031C6. Click Next.
    The MCU/MPU Selector and Board Selector tabs, with Board Selector circled, and the label Selected device: NUCLEO-C031C6.
    Figure D.2.3. The Board Selector tab, circled. Once a board is selected, its name appears beside Selected device.
    Board list with columns Commercial Part No, Reference and Core; the NUCLEO-C031C6 row, reference STM32C031C6Tx, core Arm Cortex-M0plus, is highlighted and boxed in red.
    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.
  4. Enter TemplateProject for the Project Name and accept all selected options (C for the targeted language, Executable for the targeted binary type). Click Finish.
    Setup STM32 project page with TemplateProject entered as the project name, the Location field blanked out, C and Executable selected, and Finish circled.
    Figure D.2.5. The project setup page. On your computer the Location field shows the path to the workspace folder inside your ES28 folder; it is blanked out here.
  5. The IDE opens with a set of folders pre-created, among them Inc, Src and Startup.
  6. Inside Src, delete main.c and keep the remaining files, syscalls.c and sysmem.c. We delete main.c because every program you’ll add to a copy of this project has its own main() function, and a project can have only one main() function.
  7. Right-click on TemplateProject and select Properties. In the window that opens, expand the C/C++ General menu item on the left and click on Paths and Symbols.
  8. 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 only Inc, Src and Startup at this point.
    Properties for TemplateProject, Paths and Symbols, Source Location tab, with C/C++ General, Paths and Symbols, the tab and the Link Folder button circled.
    Figure D.2.6. The Source Location tab of Paths and Symbols, with Link Folder… circled.
  9. 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.
  10. Navigate to your ES28 folder, and inside it select Library, then click Open. On Windows this button says Select Folder.
  11. Click OK in the remaining window, then Apply and Close in the Properties for TemplateProject window.
  12. In the Project Explorer on the left of your IDE, expand the Library folder and inside it the chipheaders folder. You should be able to see Device and Include, and, beside chipheaders, mylib.
    Project Explorer tree of TemplateProject with Library expanded, and the Device, Include and mylib folders circled.
    Figure D.2.9. TemplateProject in the Project Explorer with the linked Library folder expanded. Device and Include are inside chipheaders; mylib holds ES28.h and sysinit.c.
  13. For each of these three folders, right-click the folder, select Add/remove include path…, keep the defaults, and click OK.
    Project Explorer tree of TemplateProject above a context menu opened on a folder in Library; the middle of the menu is cut out, and Add/remove include path is circled.
    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.
    Select configurations to modify popup, with Debug and Release both checked and the OK button at the bottom right.
    Figure D.2.11. The popup that follows Add/remove include path…, with both configurations, Debug and Release, checked by default.
  14. Right-click (again!) on TemplateProject in the Project Explorer and select Properties. As before, expand the C/C++ General menu and select Paths and Symbols.
  15. Select the Symbols tab and click Add.
    Paths and Symbols, Symbols tab, listing DEBUG, NUCLEO_C031C6, STM32, STM32C0 and STM32C031C6Tx, with the Add button circled.
    Figure D.2.12. The Symbols tab of Paths and Symbols, before the new symbol is added.
  16. 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 header stm32c0xx.h is 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.
    Add symbol popup with STM32C031xx typed in the Name field and OK circled.
    Figure D.2.13. The Add symbol popup with STM32C031xx entered as the name.
  17. Make sure what you see is this list:
    Symbols tab listing six symbols ending in STM32C031xx; the list and the Symbols tab are circled.
    Figure D.2.14. The finished symbol list: DEBUG, NUCLEO_C031C6, STM32, STM32C0, STM32C031C6Tx and STM32C031xx.
  18. 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.