cancel
Showing results for 
Search instead for 
Did you mean: 

building a template project with keil and standard peripheral library stm32f4xx

salahuddinash
Associate II
Posted on March 21, 2014 at 14:18

Hi everyone, 

I'm a newbie with <b>stm32f4Discovery kit</b> and with <b>keil</b> too 

I'm trying to use the standard library peripheral downloaded from st website 

I've downloaded <b>STM32F4xx_DSP_StdPeriph_Lib_V1.3.0</b> library but I've tried for over 5 days to learn how to built a template for the projects I'm gonna build afterwards, I've searched the web for any tutorial but none was good with my case, So I'm asking for your help to help me with 

-how to divide the groups in keil 

-which files to add in each group

-how to manage the project folder in my HD, what sub-folders do I want to build and what files to put in each folder

-how to include the headers in keil 

at the end of following your answer I hope to have a project that I can modify with the task I want to build and build it without any warnings or errors and can burn it on the microcontroller without any problem .. 

Thanks very much in advance
7 REPLIES 7
Posted on March 21, 2014 at 14:31

The first two points, do what ever you want, it's purely cosmetic. You could dump them in a single group if that matches your sensibilities.

Try reviewing the TEMPLATE project provided :

STM32F4xx_DSP_StdPeriph_Lib_V1.3.0\Project\STM32F4xx_StdPeriph_Templates\MDK-ARM

I have the library installed under my Keil 4 tree :

C:\Keil4\ARM\Examples\ST\STM32F4xx_DSP_StdPeriph_Lib_V1.3.0\

I build my projects in the project portion of the tree :

C:\Keil4\ARM\Examples\ST\STM32F4xx_DSP_StdPeriph_Lib_V1.3.0\Project\Demo1

You could try uV5 too, but I'd not recommend it

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
salahuddinash
Associate II
Posted on March 21, 2014 at 20:41

At the first place, thank you very much  for your time and concern, and I hope you be patient with me till the end of that 

The first two points, do what ever you want, it's purely cosmetic. You could dump them in a single group if that matches your sensibilities.

I know that but I want to know the standard and what files do I need basically to build a project using standard peripheral library without errors

Try reviewing the TEMPLATE project provided :

 

STM32F4xx_DSP_StdPeriph_Lib_V1.3.0\Project\STM32F4xx_StdPeriph_Templates\MDK-ARM

 

I've tried to copy the files found in  STM32F4xx_DSP_StdPeriph_Lib_V1.3.0\Project\STM32F4xx_StdPeriph_examples like those found in gpio example then I pasted them in the folder 

STM32F4xx_DSP_StdPeriph_Lib_V1.3.0\Project\STM32F4xx_StdPeriph_templates and then opend the project found in STM32F4xx_DSP_StdPeriph_Lib_V1.3.0\Project\STM32F4xx_StdPeriph_Templates\MDK-ARM then I opened project options Alt+F7 and a popup window appears with '' Project is [Read-only], any modifications can't be saved '' then the options window appears, and from device tab I chose my microcontroller ''stm32f407VG'' then ''OK''

After that when compiling F7, 38 errors and 181 warnings are the result and the ''target not created''

I have the library installed under my Keil 4 tree :

 

C:\Keil4\ARM\Examples\ST\STM32F4xx_DSP_StdPeriph_Lib_V1.3.0\

 

In fact this was the only project that I could successfully compile and burn on the kit, that blinky example found in 

Keil_v5\examples\Boards\ST\STM32F4-Discovery\Blinky

but there was just this example and it doesn't use the standard peripheral library, but I want to use it in my projects 

You could try uV5 too, but I'd not recommend it

 

I'm using uV5 but as a newbie I don't know the difference between it and uV4 and why you don't recommend using uV5?

Posted on March 21, 2014 at 21:05

It's the information in the ''options'' of the project which are critical, the grouping of files is not.

What's critical, well pathing of include files, defines passed to the compiler. You need startup_stm32f4xx.s file, stm32f4xx_conf.h and system_stm32f4xx.c

For peripherals, you'll need the specific files like stm32f4xx_rcc.c, stm32f4xx_gpio.c , etc to support the functions you actually use. The simplest route is to dump all the library source in and let the linker figure it out, and do dead code elimination.

Depending on how you unpack the library archive the files/directories will be marked READ ONLY, clone the directory, and then change it's attributes to clear the Read Only attribute. Use a file manager of your choice to achieve this, or right click.

Creating projects from scratch requires a lot of skill, and familiarity with the tools.

uV5 breaks things that were working with CMSIS and the ST Libraries in uV4, you also have to load a bunch of packs to make things work. I'll wait till in matures, thank you.
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
salahuddinash
Associate II
Posted on March 22, 2014 at 00:01

The first thing I'd like to ask about, what are those 38 errors and 131 warnings ? 

I just used the template in the standard peripheral library?

It's the information in the ''options'' of the project which are critical, the grouping of files is not.

What's critical, well pathing of include files, defines passed to the compiler. You need startup_stm32f4xx.s file, stm32f4xx_conf.h and system_stm32f4xx.c

this point I want to understand properly, cause in the only project that worked well with me and blinked the leds on the board,

there were no included paths in the

 

project options->C/C++->include paths, but it worked??!

and another question, what is the importance of startup_stm32f4xx.s file? I checked it out and there was some code about stack and something like that but I searched for its function but didn't find any tutorial!!

another question, when do I have to include .h files and when to include .c or .s files ?? 

as you mentioned I have to include stm32f4xx_conf.h what about the stm32f4xx.c?

 

and system_stm32f4xx.c what about system_stm32f4xx.h?

another question, what are the defines passed to the compiler? what is their importance? 

I found some thing like that in the blinky working example

''HSE_VALUE=8000000''

 

and found some thing like that

''USE_STDPERIPH_DRIVER,STM32F401xx''

 

what does this mean and how is there a specific thing to define in all projects or it varies and how to know?

For peripherals, you'll need the specific files like stm32f4xx_rcc.c, stm32f4xx_gpio.c , etc to support the functions you actually use. The simplest route is to dump all the library source in and let the linker figure it out, and do dead code elimination.

 

a question, do I have to include those too in the ''project options '' or just adding them in the groups ? 

and here you talked about stm32f4xx_gpio.c, what about stm32f4xx_gpio.h?

Depending on how you unpack the library archive the files/directories will be marked READ ONLY, clone the directory, and then change it's attributes to clear the Read Only attribute. Use a file manager of your choice to achieve this, or right click.

I solve this problem by right click as you said, thank you 🙂 

Creating projects from scratch requires a lot of skill, and familiarity with the tools.

 

How can I learn these stuff? by practice or are there a good tutorial doubtly about this? I searched the google up down for a good thing but didn't find any? how did you learned these stuff?

uV5 breaks things that were working with CMSIS and the ST Libraries in uV4, you also have to load a bunch of packs to make things work. 

Honestly, I don't know what do you mean with that ? 

and if I exchanged uV5 by uV4, will that solve my problems?

I hope you don't give up helping 

Thanks a lot
Posted on March 22, 2014 at 00:29

I read the manuals, practiced and experimented. I learned to program before the internet existed, in a time where it helped to be self-sufficient.

I'm sure there's stuff in video form via Google, YouTube, etc.

You're getting a bunch of errors in uV5, I can use the template project, and others in the firmware libraries without issues in uV4, my choice not to migrate seems quite sound.

All the project structuring you need is in the template, you need to download an evaluation copy of uV4, and review/analyze the project configuration.

You don't have to add include files to a project, the tools will find what you have #include'd provided you have set up paths to the directories (Libraries / Utilities) where they are located. Some of the project/board specific files like system_stm32f4xx.c and stm32f4xx_conf.h should be localized in your project folder. The configuration (conf) file is loaded via the #include ''stm32f4xx.h'' or ''stm32f4_discovery.h''

/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Attachments/39614/keilf4proj.png

________________

Attachments :

keilf4proj.png : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I1L7&d=%2Fa%2F0X0000000blX%2FnTbSMrY1mbT_osNAhMq4h4gFTULMbea6wjdDehqppMw&asPdf=false
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
salahuddinash
Associate II
Posted on March 23, 2014 at 04:19

Thanks a lot sir, really you're helping me and I began to see the whole picture now.

I've tried implementing a program using your advises in linking and including files 

and I was able to do it right except one error appeared ... 

Undefined Symbol asser_param (referred from misc.o)

and I did my best to solve this error but couldn't, so if you help me with this, I'll be so grateful, thanks a lot for your concern and for your time
Posted on March 23, 2014 at 04:28

Same topic, different thread

[DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Undefined%20symbol%20assert_param%20%28referred%20from%20misc.o%29%20in%20keil%20with%20stm32f407&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&TopicsView=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/AllItems.aspx&currentviews=18]https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fcortex_mx_stm32%2fUndefined%20symbol%20assert_param%20%28referred%20from%20misc.o%29%20in%20keil%20with%20stm32f407&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&TopicsView=https%3A%2F%2Fmy.st.com%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2Fcortex_mx_stm32%2FAllItems.aspx¤tviews=18
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..