2010-11-30 11:30 PM
How to use STM32F10x Standard Peripherals Library ?
2011-05-17 05:16 AM
''I'm trying to make a project with STM32F10x Standard Peripherals Library''
What tools have you used? Have you been able to successfully build any of the example projects?''received lots of errors.'' What errors, exactly?''Am I doing anything wrong?'' Apart from just saying, ''yes - you must be!'', It is very hard to answer when you don't say what specific problems you are actually having. What steps have you taken to debug these errors? Dealing with build errors is an essential part of software development - are you experienced in doing this?
2011-05-17 05:16 AM
Just looks like the library files, not seeing a project.
2011-05-17 05:16 AM
Thank you for this fast reply
I wanna use STM32F10x Standard Peripherals Library which is full CMSIS compliant I use Keil Uvision4(Real View) and follow stm32f10x_stdperiph_lib_um.chm to make a project(at the end of first page ''How to use the Library'') I try to make a very simple project to just use stm32f10x_rcc.h to configure RCC and nothing else Here is the code that I've writte: /* Includes ------------------------------------------------------------------*/ #include ''stm32f10x.h'' /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ /* Private macro ------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ GPIO_InitTypeDef GPIO_InitStructure; ErrorStatus HSEStartUpStatus; /* Private function prototypes -----------------------------------------------*/ void RCC_Configuration(void); /* Private functions ---------------------------------------------------------*/ /******************************************************************************* * Function Name : main * Description : Main program. * Input : None * Output : None * Return : None *******************************************************************************/ int main(void) { /* System Clocks Configuration **********************************************/ RCC_Configuration(); while(1) { } } /******************************************************************************* * Function Name : RCC_Configuration * Description : Configures the different system clocks. * Input : None * Output : None * Return : None *******************************************************************************/ void RCC_Configuration(void) { /* RCC system reset(for debug purpose) */ RCC_DeInit(); /* Enable HSE */ RCC_HSEConfig(RCC_HSE_ON); /* Wait till HSE is ready */ HSEStartUpStatus = RCC_WaitForHSEStartUp(); if(HSEStartUpStatus == SUCCESS) { /* Enable Prefetch Buffer */ FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable); /* Flash 2 wait state */ FLASH_SetLatency(FLASH_Latency_2); /* HCLK = SYSCLK */ RCC_HCLKConfig(RCC_SYSCLK_Div1); /* PCLK2 = HCLK */ RCC_PCLK2Config(RCC_HCLK_Div1); /* PCLK1 = HCLK/2 */ RCC_PCLK1Config(RCC_HCLK_Div2); /* PLLCLK = 8MHz * 9 = 72 MHz */ RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9); /* Enable PLL */ RCC_PLLCmd(ENABLE); /* Wait till PLL is ready */ while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET) { } /* Select PLL as system clock source */ RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK); /* Wait till PLL is used as system clock source */ while(RCC_GetSYSCLKSource() != 0x08) { } } } and Here is some of the errors that I've received: D:\Program files\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(23): error: #256: invalid redeclaration of type name ''s32'' (declared at line 312 of ''D:\Program files\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h'') D:\Program files\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(27): error: #256: invalid redeclaration of type name ''sc32'' (declared at line 316 of ''D:\Program files\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h'') D:\Program files\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(35): error: #256: invalid redeclaration of type name ''vsc32'' (declared at line 324 of ''D:\Program files\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h'') D:\Program files\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h(55): error: #256: invalid redeclaration of type name ''bool'' (declared at line 345 of ''D:\Program files\Keil\ARM\INC\ST\STM32F10x\stm32f10x.h'') Std_Second.c(68): error: #20: identifier ''RCC_HSE_ON'' is undefined Std_Second.c(85): error: #20: identifier ''RCC_HCLK_Div1'' is undefined Std_Second.c(91): error: #20: identifier ''RCC_PLLSource_HSE_Div1'' is undefined I'm sure that the problem is in my project structure because when I use this code in stm32f10x_stdperiph_lib\STM32F10x_StdPeriph_Lib_V3.4.0\Project\STM32F10x_StdPeriph_Template\MDK-ARM, it works fine! but I can't understand error source because all of added files in project are same(startup_stm32f10x_md.s , header files , source files , CMSIS files) would you please run my project(MY_STM32_Std_Peroph_Lib_Second.zip) and tell me what is wrong ? thanks for regards2011-05-17 05:16 AM
Cross post:
2011-05-17 05:16 AM
I believe the compiler/linker is trying to use the Keil STlibs rather than the newer V3.4.0 libs that you have. You need to change your include path so that it points to the V3.4.0 includes. For example, I have ''C:\STlib\STM32F10x_StdPeriph_Lib_V3.4.0\Libraries\STM32F10x_StdPeriph_Driver\inc'' in my include path.
In my project, when I use a peripheral, I add the associated source file (stm32f10x_rcc.c for example) to my project (just a link, I don't copy the file). So that it compiles in my project. I also put a copy of the stm32f10x_conf.h file in my project because that is where you enable/disable the includes for various peripherals. Use a copy of the stm32f10x_conf.h file since every project will use different peripherals. To set your include path, right click on the ''Target 1'' name in your project (you may have changed that name) and go to the ''C/C++'' tab. In the ''Include Paths'' you add where you've unzipped the STLIB files. For instance, I have: C:\STlib\STM32F10x_StdPeriph_Lib_V3.4.0\Libraries\CMSIS\CM3\CoreSupport;C:\STlib\STM32F10x_StdPeriph_Lib_V3.4.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x;C:\STlib\STM32F10x_StdPeriph_Lib_V3.4.0\Libraries\STM32F10x_StdPeriph_Driver\inc;.\ Also on the ''Define'' line I have: STM32F10X_HD, USE_STDPERIPH_DRIVER The basic idea is to put the 3.4 libs ahead of the 2.x libs that Keil has in their installation. --William2011-05-17 05:16 AM
''I believe the compiler/linker is trying to use the Keil STlibs rather than the newer V3.4.0 libs that you have.''
Note that there is no such thing as ''Keil STlibs'' - Keil simply redistribute the ST library as a verbatim copy. Naturally, there is a certain delay between ST releasing a new library and Keil geting it into their distributions - hence the reason why the one included with the Keil distribution may well be older than the latest direct from ST. Such is life.''The basic idea is to put the 3.4 libs ahead of the 2.x libs that Keil has in their installation.'' Unless you have a specific reason to keep the old library (which seems unlikely for a newbie), it's probably better to just delete it completely - then at least you'll know by the error messages when it's trying to use the wrong version!2011-05-17 05:16 AM
Hi friends
I changed path of inc & src files to new version of stm32f10x_lib but the problem is some errors. one of then isD:\Keil\ARM\INC\ST\STM32F10x\stm32f10x_type.h
(23): error: #256: invalid redeclaration of type name ''s32'' (declared at line 470 of ''.\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x\stm32f10x.h'') There is no stm32f10x_type.h in new version ! It's very unusual when I copy my code in stm32f10x_stdperiph_lib\STM32F10x_StdPeriph_Lib_V3.4.0\Project\STM32F10x_StdPeriph_Template, there is no error after compile ! path of inc & src files in both project are same so what's the problem ? Is there any thing that I have forgotten to add in my project ? Thank you very much2011-05-17 05:16 AM
If you're going to post the same question on multiple forums, then it's up to you to monitor the answers that you get on all those forums.
This question (''Keil and error 256'') has already been answered here:2011-05-17 05:16 AM
Hi friends
I found that best reference is AN2953 Application note (How to migrate from the STM32F10xxx firmware library V2.0.3 to the STM32F10xxx standard peripheral library V3.0.0 ) It's very useful