VIDEO: How to set up a Keil IDE 5 Project


Hello and welcome to a short video which will cover how to set up a Keil Micro vision 5 project for use with programming the STM32F4 Discovery Board. There is a written version of this tutorial available if you would prefer, the link is in the description.

Firstly, this tutorial assumes that you have keil microvision already installed. If not, it is a straightforward download from the Kiel site, linked below.

When opening keil microvision you are presented with a few panels that I will go over briefly. On the left, you have the project panel which contains all files attributed to the current project. On the bottom you have the build output which will display the progress of the build task along with any errors or warnings. The top toolbars contain many shortcut buttons, some of which will be used in this tutorial.

If this is the first time you have used keil microvision for programming the discovery board, you will need to install some packages which contain all the necessary files to program the discovery.

This is quite straightforward, simply click the pack installer icon and allow the list of packs to load. Select the boards tab and then select the pack for the STM32F4 discovery board and press install. You can then close this window once the installation is complete, it may take a few minutes.

Now we can create a new project. Select the project menu from the top and press “New Microvision Project”. Choose a suitable name and location for your project files.

Now we need tell keil which microprocessor we are using. Expand the STM menu and find the STM32F407VGTx option. Press okay. You may get an error here like this but you can ignore this.

In the window which pops up next, we need to select the software components which you will be using in your project. Firstly, select the STM32F4 Discovery from the board support drop down menu. Next under CMSIS tab, select CORE. Under the Device tab select STARTUP. Then select the Classic framework under the STM32Cube Framework Menu.

To remove any orange boxes that might appear simply click the resolve menu at the bottom left.

Now under the STM32Cube Hardware Abstraction Layer menu select the components which you will be using in your project. For example I2C and SPI communication interfaces. Again, pressing resolve will remove those orange boxes. This menu can be accessed later from the manage run time environment button in the toolbar if you have forgotten a pack you wish to include.

Now we must configure the compiler settings so it can correctly build programs for the discovery board. Select the options for target button in the top toolbar.

On the Target Tab, change the External Resonator Frequency to 8MHz. We can leave the output, listing and user tabs as defaults for now.

Under the “C/C++” tab we need to tell the compiler that we are using the hardware abstraction layer drivers, so under pre-processor symbols write USE_HAL_DRIVERS as shown on screen. We also need to tell the compiler where to find the any header files we will make. Select the include paths button, then new, then the dotted button then navigate to the folder where saved your project files. Press okay and okay again.

The Assembly, ASM, tab and the linker tab can be left at default settings.

Now under the debug tab we want to tell the Debugger that we want to program the actual discovery board. Select the ST-Link Debugger from the drop-down menu. Then press settings. If you see no ST-link detected and you have plugged in the discovery board, then you may need to download the STlink utility from the ST Electronics website.

Select the STSW-LINK009 page and download via the get software button. Unzip the downloaded files and follow the instructions in the read-me document.

Now going back to the debugger settings you should be able to see the software device. Under the flash downloads tab check the Reset and run checkbox. The entry under the programming algorithm should be set to this as default. If not, remove and re-add the entry with these values. Press okay to close.

Leave the utilities tab at defaults.

Hit okay to close. You have now set-up a project for the STM32F4 Discovery board! Lets do something with it now. Right click the source group 1 folder and select add new item. Select a C file and name it main. Press add. Now I am going to copy and paste a test LED blink program to the main file. You can find this on my website linked below. Another tutorial will explain how this works, keep an eye out for that!

Build the program using the build button or the F7 keyboard shortcut. You should see it build without errors. Now lets upload it to the discovery board. Press the download button or the F8 shortcut. The code has now been uploaded to the discovery board indicated by the Programming Done output in the build output window.

The LEDs on your STM32F4 discovery board should now be blinking on and off.

Thank you for watching, if this video has helped you, please like the video and consider subscribing. Thank you.


If this tutorial was helpful to you, please check out the other projects or tutorials here.

Leave a comment

Your email address will not be published. Required fields are marked *