cancel
Showing results for 
Search instead for 
Did you mean: 

starting STM32

samiassaad
Associate II
Posted on March 07, 2011 at 11:42

starting STM32

8 REPLIES 8
ColdWeather
Senior
Posted on May 17, 2011 at 14:26

Hi!

For me it seems you have mixed the actual V3.3 / V3.4 of the ''STM32F10x Standard Peripherals Library'' with the older one (V2.x). Unfortunately, KEIL suggests to include ''stm32f10x_lib.h'' that supposes the legacy library, but you need to include ''stm32f10x.h'' for the actual version instead and modify ''stm32f10x_conf.h'' that can be found in examples and should be copied into your project directory and properly customized.

Read the help file to V3.3/V3.4 and ''Description of Peripheral's driver and CMSIS files'' there to see the structure of the header files to be included.

samiassaad
Associate II
Posted on May 17, 2011 at 14:26

Thank you for replay

my problem is how to use the new library version with keil

could you explan step by step , please  ?

ColdWeather
Senior
Posted on May 17, 2011 at 14:26

> could you explan step by step , please  ?

  1. Download the actual

    http://www.st.com/internet/com/SOFTWARE_RESOURCES/SW_COMPONENT/FIRMWARE/stm32f10x_stdperiph_lib.zip

    and unzip it into some directory like ''\KEIL\ARM\INC\ST\STM32F10x_StdPeriph_Lib_V3.4.0'' for example.
  2. Find there a help file ''stm32f10x_stdperiph_lib_um.chm'', open it and read the chapter ''Description of Peripheral's driver and CMSIS files'' and ''How to use...'' (links - on the main page).
  3. Open with KEIL a project found in ''\KEIL\ARM\INC\ST\STM32F10x_StdPeriph_Lib_V3.4.0\Project\STM32F10x_StdPeriph_Template\MDK-ARM''
  4. Adjust the project to your needs.

samiassaad
Associate II
Posted on May 17, 2011 at 14:26

Thank you for help

the document told that i must choose a device , my device is stm32f105VC CL

so I want to add the line 

#define STM32F10X_CL

but the file #include ''stm32f10x.h'' is locked and i cant modify it

what is the problem ?

regards

ColdWeather
Senior
Posted on May 17, 2011 at 14:26

ColdWeather
Senior
Posted on May 17, 2011 at 14:26

The definition is to add as a preprocessor symbol in KEIL under ''project options -> C/C++.'' Exactly, the line should contain at least two symbol defines:

USE_STDPERIPH_DRIVER, STM32F10X_CL

ColdWeather
Senior
Posted on May 17, 2011 at 14:26

I have found in one of my projects notes, I wrote for myself:

//                 

//        1. The template project from the STM32F peripheral library has relative

//           paths in the project options, so the enviroment of the project must

//           be rearranged after the template has been copied into the user

//           directory structure. Besides, the *.c CMSIS and ST Peripheral

//           library files in the project file groups must be relinked.

//

//           Another way to add ST Peripheral library is to use

//           ''\KEIL\ARM\RV31\LIB\ST\STM32F10xR.LIB'' in the project.

//   

//            STM32F10xR.LIB - compiled from V3.4 sources!

//            STM32F10xD.LIB - with debug informations

//

//        2. Any project for STM32F to include ''stm32f10x.h'': this is the file,

//           that contains all the CMSIS compatible definitions and includes,

//           on its turn, the CMSIS ''core_m3.h'' and ''system_device.h'' headers.

//           The file is refered by every library file! By the way, uVision4

//           suggests to include the header named    ''stm32f10x_lib.h'' but the

//           file seems to be obsolete (V2.x against V3.x.x of ''stm32f10x.h'')

//           although a lot of internet examples include the old file making

//           it neccessary to edit examples to conform V3.x.x.

//

#include <stm32f10x.h>

//

//        3. The ST peripheral library to be used, USE_STDPERIPH_DRIVER should

//           be defined in the project options for C/C++. In this case the

//           file ''stm32f10x.h'' refers to some ''stm32f10x_conf.h'', that, on its

//           turn, is PROJECT SPECIFIC and must be provided by user and -

//           very important! - must be placed into some directory listed in the

//           ''include paths'' to be accessible for compiler while processing the

//           library files.

//

//           Various ''stm32f10x_conf.h'' can be found in the examples: the main

//           purpose of the header file is to define an assert function.

//

//           As soon as this header file MUST exist, it can include other library

//           and project specific headers like

//           suggested in ''stm32f10x_conf.h'', but this approach is optional.

//

//           In general the following paths to set:

//

//           .\;\KEIL\ARM\INC\ST\STM32F10x , where:

//

//           .\                             to reach project's ''stm32f10x_conf.h'',

//           \KEIL\ARM\INC\ST\STM32F10x      to reach device and library files *).

//

//           *) The device and library files have been copied together to

//              this folder from the actual library folder 

//                ''KEIL\ARM\INC\ST\STM32F10x_StdPeriph_Lib_V3.4.0\Libraries''

//              for convenience (to keep the paths shorter).

//

//            The path \KEIL\ARM\INC        is a default project option and thus

//                                        does not need to be set explicitly.

//

//         4. In the project options for C/C++ the target microcontroller derivate

//           must be defined, like STM32F10X_MD. Otherwise STM32F10X_XL is a //default.

//           See ''stm32f10x.h'' for possible definitions.

//

//                NOTE: Be carefull with optimization Level -O3!

//                      The program compiled with it striked to work; but -O2 was OK

//

//        5. As usual, the proper startup file ''startup_stm32f10x_YY.s'', where YY is

//           a ST device derivate, must be a component of the project and can be copied

//           into the user project directory if intended to be modified. The startup

//           files can be found in the /startup folder deep in the library directory

//           structure or combined in ''\KEIL\ARM\Startup\ST''.

//

//        6. Also ''core_cm3.c'' and ''system_stm32f10x.c'' files (see CMSIS rules and

//           P.2. above) must be a part of the project. The ''system_stm32f10x.c'' file

//           used to be copied into the user project directory because it will be

//           mostly modified in the project (like clock settings, etc...).   

//

samiassaad
Associate II
Posted on May 17, 2011 at 14:26

Thank you all alot :)

I think I am in the right way right now , if I get problems I will be back

Regards