You are likely playing with your MDK-ARM uVision4 IDE with default examples provided by the ST firmware.
But each time you try to change something you see a message saying that the project is read only.
Therefor in this tutorial we will create our own project by copying an example provided in order to customize it.
All the tutorial will use the STM32F3-DISCOVERY board but it should of course work with other boards.
Our workspace will be:
Let's assume that we installed the ST firmware in this directory:
Then let's copy the Libraries and Utilities directories in our own workspace.
We will create a __firmware directory to put both Libraries and Utilities.
So copy all files from:
Our project will be created in this folder:
Then add a directory to badprog_adc called user and copy all files from:
into this user folder.
We have so:
As all those files are read only, right click the H:\dev\mcu\keil\badprog_adc\user directory and Properties > in Attributes, disable the Read only checkbox and click Apply > Apply all modification to sub folders.
Now check that each file in the user directory is not read only.
Right click one file and Properties.
Attributes should have Read only disabled.
If all files are like this one, let's continue!
For this first project we are going to copy the ADC example.
Open the IDE then > Project > New uVision Project...
Select the badprog_adc directory and name the file badprog_adc.uvproj and click Save.
A window appears to choose your device. For this tutorial we are using the STM32F3-DISCOVERY board.
And the microcontroller is a STM32F303VCT6.
So in the list, we select > STMicroelectronics > STM32F303VC > OK.
A new window popups asking if you would like to Copy 'startup_stm32f30x.s' to Project Folder and Add File to Project ?
Click the Yes button.
This file is added automatically and is the same as the one you can find in the following directory:
Now in the Project window, we can see:
Target
Source Group 1
startup_stm32f30x.s
Let's rename Target 1 to myADC and Source Group 1 to MDK-ARM-startup.
So the new arborescence is:
myAdc
MDK-ARM-startup
startup_stm32f30x.s
We are now going to create groups and files.
Still in the Projec window, right click on myADC > Add Group...
A group is added with the name New Group.
To change this name, left click it and click on the F2 key on your keyboard.
Let's name it src.
Right click src > Add Files to Group 'src'...
Then select all .c files in:
We have now this arborescence:
myAdc
MDK-ARM-startup
startup_stm32f30x.s
src
main.c
stm32f30x_it.c
system_stm32f30x.c
Let's add a new group called STM32F3-DISCOVERY with files taken from:
Our tree is:
myAdc
MDK-ARM-startup
startup_stm32f30x.s
src
main.c
stm32f30x_it.c
system_stm32f30x.c
STM32F3-Discovery
stm32f3_discovery.c
We will add a last directory called STM32F30x_StdPeriph_Driver and files taken from:
We don't need all files, so let's take only ones we will use for our ADC example.
So our arborescence is finally:
myAdc
MDK-ARM-startup
startup_stm32f30x.s
src
main.c
stm32f30x_it.c
system_stm32f30x.c
STM32F3-Discovery
stm32f3_discovery.c
STM32F30x_StdPeriph_Driver
stm32f30x_adc.c
stm32f30x_exti.c
stm32f30x_gpio.c
stm32f30x_misc.c
stm32f30x_rcc.c
stm32f30x_syscfg.c
Right click myADC > Options for Target 'myADC'... > C/C++ > Preprocessor Symbols > Define > write USE_STDPERIPH_DRIVER,STM32F30X,
Still in the options > C/C++:
Still in the options > C/C++, in the Include Paths part, click the button at right with "..." and insert the following paths for includes:
Now still in the options > Linker > enable Use Memory Layout from Target Dialog.
Still in the options > Debug > On the right, select ST-Link Debugger.
Still in the options > Debug > On the right, enabled Run to main().
Still in the options > Debug > On the right, click the Settings button:
Still in the options > Utilities > Configure Flash Menu Command > Use Target Driver for Flash Programming > select ST-Link Debugger.
Finally click OK.
We can now build our project > Project > Rebuild all target files.
In the Build Output we should see the following output:
Rebuild target 'myADC' assembling startup_stm32f30x.s... compiling main.c... compiling stm32f30x_it.c... compiling system_stm32f30x.c... compiling stm32f3_discovery.c... compiling stm32f30x_adc.c... compiling stm32f30x_exti.c... compiling stm32f30x_misc.c... compiling stm32f30x_rcc.c... compiling stm32f30x_syscfg.c... compiling stm32f30x_gpio.c... linking... Program Size: Code=1612 RO-data=424 RW-data=40 ZI-data=1688 "badprog_adc.axf" - 0 Error(s), 0 Warning(s).
Select now > Flash > Download.
The program is sent to the board!
If all is OK, the following ouput should appear:
Load "H:\\dev\\mcu\\keil\\badprog_adc\\badprog_adc.axf" Erase Done. Programming Done. Verify OK. Application running ...
You are now able to change what you want on your files, created, and of course save them.
It was not so easy, but well done, you've made it!
Comments
Vikas (not verified)
Sunday, June 16, 2013 - 4:47pm
Permalink
Very useful.. Thanks a lot!!
Very useful..
Thanks a lot!!
Huzaifa (not verified)
Sunday, May 1, 2016 - 8:44am
Permalink
I followed all the steps but
I followed all the steps but 10 errors appeared of core cm4.h not included
Add new comment