2015-05-22 10:33 PM
Hello again,
Im decided to switch my first project stm32 from the HAL driver library to the SPL. I was able to get a blinky program working using the STCubeMX software and Kei1 with the HAL drives, but i want to write the code om my own in Eclipse. Everything seems to be working, but i can't figure out why i cannot resolveRCC_AHB1PeriphClockCmd(). I believe i have included all the necessary files. I went intostm32f10x_conf.h
and uncommented _gpio.h, _rcc.h, and alsouncommitted#define STM32F10X_MD and#define USE_STDPERIPH_DRIVER in
stm32f10x.h
but im still getting errors. I also tried to include _rcc.h directly into main as you can see in my code with no luck. Anysuggestions?#include <
stm32f10x.h
>
#include <
stm32f10x_conf.h
>
#include <
stdio.h
>
#include <
stdlib.h
>
#include ''diag/Trace.h''
#include ''stm32f1-stdperiph\stm32f10x_rcc.h''
#define GPIO_PORT GPIOC
#define GPIO_PIN GPIO_PIN_13
//Prototypes
void GPIO_Init(void);
GPIO_InitTypeDef GPIO_InitStruct;
int main(/*int argc, char* argv[]*/)
{
// At this stage the system clock should have already been configured
// at high speed.
// Infinite loop
while (1)
{
// Add your code here.
}
return 0;
}
void GPIO_Init(void) {
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
}
2015-05-23 01:07 AM
You can always open .h (in your case _rcc.h) file and check how it is designed.
F10x devices does not have AHB1, AHB2, AHBx.. but only AHB.So, you have to do it like this:RCC_AHBPeriphClockCmd(RCC_AHBPeriph_PERIPHNAME, ENABLE);Btw..GPIOs are on APB2 bus, so:RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);2015-05-23 04:40 AM
You'd really want to review the templates for other platforms, and have the IDE pass the USE_STDPERIPH_DRIVER define to the compiler.
Your project will also need to actually include the individual library source files you are using, ie stm32f1xx_gpio.c, stm32f1xx_rcc.c so the linker actually has some function to bind against. Just #including definitions and prototypes does not achieve this.2015-05-23 11:26 AM
Thanks majerle for the insight. I just got it working. Strange because in the SPL API reference sheet it said to useAHB1. Maybe I missed something.
Clive1, I was wondering about that. My code is workingwithout
including rcc.c and gpio.c files. I went into the *.h files and didn't see any include *.c statements. Any idea what the compiler/linker is doing? Working code for reference.#include <
stm32f10x.h
>
#include <
stm32f10x_conf.h
>
#include <
stdio.h
>
#include <
stdlib.h
>
#include ''diag/Trace.h''
#define GPIO_PORT GPIOC
#define GPIO_PIN GPIO_PIN_13
//Prototypes
void GPIO_Init(void);
GPIO_InitTypeDef GPIO_InitStruct;
int main(/*int argc, char* argv[]*/) {
while (1) { }
return 0;
}
void GPIO_Init(void) {
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP;
}
2015-05-23 12:02 PM
Does anyone know where i can find the STM32F1xx Standard Peripheral Library PDF? Currently i'm using STM32F2xx Standard Peripheral Library and its causing me a lot of problems.
2015-05-26 11:36 PM
Why would you need PDF for that?
Open .c file of your driver, there is vell explained everything you need.