cancel
Showing results for 
Search instead for 
Did you mean: 

Hard fault with stm32 std peripheral library

paulmanners9
Associate
Posted on November 13, 2014 at 12:23

Hi, 

This is a pretty noob question but I'm going to ask it anyway, because it seems like I'm missing something. 

I've just set up new STM32F1xx and STM32L1xx projects based on the GNU ARM plugin for eclipse.  I'm wanting to use the standard peripheral libraries and CMSIS goodness so that I have nice clean portable HAL interfaces going forward, that others are familiar with.

Going through the code of the RCC peripheral (stm32l1xx_rcc.c/stm32l1xx_rcc.h), I see there is reference to RCC (RCC_TypeDef *) that is defined as a macro in stm32l1xx.h (&sharpdefine RCC   ((RCC_TypeDef *) RCC_BASE)).  There doesn't seem to be any variable or pointer reference defined in the library so that it can be accessed from SRAM.  This is obviously easy to add in and is necessary if you don't want a hard fault when you call RCC->CR in your main loop, however I can't help feeling that there is an easier way around this.  Perhaps there's an include I've missed, a compiler switch or some macro  I should be using.  Having searched through the peripherals library source code, I haven't found anything indicating this.  Eventually I found what I was expecting to see, however this was in the debug project example (stm32l1xx_ip_dbg.c) and not the std libs. 

Is there an easier way to do this, I'm sure the std libs would not be incomplete as it appears?

Thanks

Paul

#header-rcc_base-system_stm32f10x
1 REPLY 1
Tamas Novak
Associate III
Posted on November 16, 2014 at 19:59

I think you can find it in ''stm32f10x.h'' header file.This is included from ''system_stm32f10x.c'', which should be added to your project. (Use the one from STM32F10x_StdPeriph_Template subdir.)