This page describes how to create a new C project manually. \\ The [[uvision|InES Pack]] also offers standardised [[example_projects|example projects]] for C and [[asm_project|Assembly]]. \\ \\ ===== 1) Prepare Project Directory ===== First create a new directory either locally, when you're using your own Laptop or on the "U:\" drive, when you're working on a ZHAW computer and name it according to the project (e.g. lab1). \\ Inside this directory create the following two directories: |< 100% 10em >| ^app|This is for the applications source code| ^build|This is for the artifacts and binaries from the build process| ===== 2) Create new Project ===== Start [[uvision|Keil uVision]] and create a new project "Project -> new uVision Project".\\ Give the file a name according to the project and save it to the previously created project-directory (lab1). \\ \\ After expanding the "STMicroeletronics" section, choose the device for which you want to create a new project. \\ \\ |< 100% 15em >| ^CT Board HS14 M0|This device uses the Cortex-M0 instruction set| ^CT Board HS14 M4|This device has full access to the Cortex-M4 instruction set| > If unclear choose **CT Board HS14 M0** for the CT Board. \\ {{keil_project_device.png?700em}} \\ \\ ===== 3) Runtime Components ===== If not already popped up, click the green button {{keil_mrt_button.png?30em}} //"Manage Run-TimeEnvironment"// to open the below shown view.\\ Expand the "Device" group and select the "Startup" component. Now click on the "Resolve" button. \\ {{keil_rte.png?800em}} \\ \\ ===== 4) Setup Debugger ===== Make sure that the CT Board is connected to the host computer!\\ \\ By default the project is configured to use the Keil uLink debugger. The CT Board uses the onboard ST-Link debugger. \\ \\ Change the configuration to "ST-Link Debugger" under "Project -> Options for Target, Target 1" in the //"Debug"// tab.\\ Then click //Settings// right next to it. \\ {{keil_debugger.png?700em}} \\ \\ Make sure the port is set to SW (Serial Wire) instead of JTAG. \\ \\ {{keil_debugger_2.png?700em}} \\ \\ Also check the //"Flash Download"// tab and make sure the "STM32F4xx 2MB Flash" algorithm is visible in the "Programming Algorithm" section. \\ Otherwise add the algorithm with the add button. \\ {{keil_debugger_3.png?700em}} \\ \\ ===== 5) Output & Listing Folder ===== Go back to "Options for Target, Target1" and select the //"Output"// tab. \\ Click "Select Folder for Objects..." and choose (double-click) the **build** folder from your created directory (lab1) as your output folder. \\ \\ Then go to the //"Listing"// tab. \\ Click "Select Folder for Listings..." and choose again (double-click) the **build** folder from your created directory (lab1) as your listing folder. \\ \\ Now open your project directory in your explorer and you will find the two self generated folders, **Listings** and **Objects**. \\ Delete them.\\ \\ {{keil_delete_folder.png?700em}} \\ \\ ===== 5) Setup Linker ===== During the linking process Keil gives a warning: \\ ''warning: L6314W: No section matches pattern *(InRoor$$Sections).'' \\ \\ To disable this warning add the following parameter to the linker arguments under\\ “Project → Options for Target, Target 1” in the "Linker" tab: \\ ''--diag_suppress 6314'' \\ {{keil_linker.png?700em}} \\ \\ ===== 6) Adding Items to Project ===== To create a new file expand the folder "Target 1", right-click on the folder "Source Group 1" and then choose "Add New Item to Group...". \\ If you want to add an existing file, choose "Add Existing Files to Group...". \\ \\ {{keil_add_file_1.png?1000em}} \\ \\ Choose the corresponding file type, name and location.\\ \\ {{keil_add_file_2.png?800em}} \\ \\ |< 100% 10em >| ^Type|Choose either "C File (.c)" or "Header File (.h)"| ^Name|Choose an appropriate name| ^Location|Choose correct [[#prepare_project_directory|location]] (.\app)|\\ \\ \\ \\ \\ //**Back to [[software:start:getting_started|Getting Started]]**//