cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with keil STM32F0 discovery

edouard
Associate II
Posted on August 05, 2015 at 23:26

Hello,

Im trying to implement a connection bewteen a STM32F0 discovery and a bluetooth module. Im using the USART2 with this code (thanks Clive1) :

/* USART2 PA.2 Tx, PA.3 Rx STM32F0-Discovery sourcer32@gmail.com */
#include ''stm32f0xx.h''
#include ''stm32f0_discovery.h''
int main(void)
{
USART_InitTypeDef USART_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_1);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_1);
/* Configure USART2 pins: Rx and Tx ----------------------------*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
USART_InitStructure.USART_BaudRate = 9600;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(USART2, &USART_InitStructure);
USART_Cmd(USART2,ENABLE);
while(1)
{
while (USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET)
USART_SendData(USART2, 'X');
}
}

I tried a new project with just one main with this code, and i linked Discovery_FW_V1.0.0\Libraries\CMSIS\Include -I..\..\STM32F0-Discovery_FW_V1.0.0\Libraries\CMSIS\ST\STM32F0xx\Include -I..\..\STM32F0-Discovery_FW_V1.0.0\Libraries\STM32F0xx_StdPeriph_Driver\inc -I..\..\STM32F0-Discovery_FW_V1.0.0\Utilities\STM32F0-Discovery I get that error : C:\Keil\Keil_v5\ARM\PACK\Keil\STM32F0xx_DFP\1.4.0\Device\Include\stm32f0xx.h(5683): error: #5: cannot open source input file ''stm32f0xx_conf.h'': No such file or directory Can you help me ? Thanks a lot.
6 REPLIES 6
lartigue
Associate II
Posted on August 06, 2015 at 00:12

Hi Jobert,

In your ''flash tool menu'' (Keil uVision), then ''C/C++'' tab, did you include the folder containing your file ?

Posted on August 06, 2015 at 00:56

The ''stm32f0xx_conf.h'' file is a project specific one, nominally you'd copy this out of the template directory, either for the DISCO, or F0 SPL, into you own project directory.

This file #include's the other component stm32f0xx_xxxx.h files for the peripherals.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
edouard
Associate II
Posted on August 06, 2015 at 09:31

0690X0000060MnEQAU.gif: Yes, I included the 3 folders with all the headers files i downloaded from the st website

Clive1: I will try it when I'm home. I will post here if I have any further problems, thanks to both of you

edouard
Associate II
Posted on August 06, 2015 at 17:50

I just added it to my project (by cut it in the folder and add it with keil) and i linked with the C/C++ menu the folder where there si my project and this file.

Now i got no error but a warning : C:\Keil\Keil_v5\ARM\PACK\Keil\STM32F0xx_DFP\1.4.0\Device\Include\stm32f0xx.h(89): warning:  #47-D: incompatible redefinition of macro ''STM32F051''

Posted on August 06, 2015 at 18:20

I use the SPL, I'm not sure that plays well with other abstractions from Keil.

Use the

http://www.st.com/web/en/catalog/tools/PF259447

, red download button at the bottom.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
edouard
Associate II
Posted on August 06, 2015 at 19:42

Hello, well i tried with uvision 4 and it seems to work ! I dont understand where this warning come from thought (im using the same version u linked of the firmware)