STM32F4 Discovery Board New Project (with the infinite loop design and without using CMSIS-RTOS RTX functions) PDF Print E-mail
Written by Monfared   

1. Install KEIL MDK.

2. Download the STM32F4-Discovery firmware package from the STMicroelectronics web site in the Related Tools and Software section,

or directly from:

This firmware package include a firmware for the STM32F407VGT6 microcontroller, a firmware for the STM32F4-Discovery board and 22 examples (covering USB Host, audio, MEMS accelerometer and microphone).


3. Download this file Useful_Files_STM32F4 that contains the source and header interruption handler files and the library configuration file.


4. From the μVision menu bar, choose Project – New μVision Project.
Select an empty folder and enter the project name, for example, New. Click Save, which creates an empty project file with the specified name (New.uvproj).


5. Select the device: STM32F407VG and click OK.
The device selection defines essential tool settings such as compiler controls, the memory layout for the linker, and the Flash programming algorithms.




6. The dialog Manage Run-Time Environment opens and shows the software components that are installed and available for the selected device. Select the required components, as seen bellow and click OK.
- More components can be added later.
- The DSP component is essential for Power Electronic projects (




The Project window displays the selected software components along with the related files. Double-click on a file to open it in the editor.




7. Click Options for Target on the toolbar and do the following settings:







Note: To correctly detect the Debug Adapter, the STM32FDiscovery must be connected to the PC.





8. In the Project window, right-click Source Group 1 and open the dialog Add New Item to Group. Click on C file (.c), enter the name and click Add:



9. In the Project window, right-click Source Target 1 and open the dialog Add Group. Name it Std_PeriphDriver.
This group must have the files which contain the firmware functions for microcontroller peripherals. These files are located in
This folder contains the entire driver necessary for the STM32F407VGT6 microcontroller. For example the Analog/Digital converter stm32f4xx_adc.c, the Digital/Analog converter stm32f4xx_dac.c, etc …


10. In the Project window, right-click Std_PeriphDriver and open the dialog Add Existing Files to Group. Add the following files:



 Note: You don’t have to add all the firmware drivers. Just add the driver that you will use it in your project. Later you will see that these firmwares greatly simplify the programming.

Note: Add the most important driver file, the misc.c. This file provides all miscellaneous firmware functions like configuring the NVIC (Nested Vectored Interrupt Controller) priority grouping etc. … and other needed files. Adding unnecessary files just slows than the Rebuild process.



11. Add associated header files. Click Options for Target on the toolbar and under the C/C++ tab click Include Paths.
- The first header file to add is the cortex M4 header file and is located under:
- The second header file to add is the system_stm32f4xx.h from:
Note: Inside the stm32f4xx.h there is a condition to include the stm32f4xx_conf.h header file. So we already typed the USE_STDPERIPH_DRIVER and the STM32F4XX in the defined Preprocessor Symbols.
- Add
- Copy the stm32f4xx_conf.h and stm32f4xx_it.h from the Useful_Files_STM32 folder to the project directory and simply select the project directory (here the folder New) in the Include Paths to refer to the project directory.
Note: The project directory and the library location (here the folder Sources) shouldn't be moved, otherwise you should modify the links.




12. The Library configuration file stm32f4xx_conf.h includes the list of all the header files of the firmware drivers. You have to uncomment all the header files that you need, here: misc.h, stm32f4xx_adc.h, stm32f4xx_dac.h, stm32f4xx_gpio.h, stm32f4xx_rcc.h, stm32f4xx_tim.h




13. Now ready to write your own program! Open the main.c file and enjoy …

Note: You can find a very useful application note and examples at