This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

problem in compiling codes

Hello there,
I am new to keil and I tried to program a stm32 with a simple blinky code.
Here is my code and after compling, i m getting a single error and i dont knw how to figure it out.
This is the error that I m being showed :

main.c(9): error: #268: declaration may not appear after executable statement in block GPIO_InitTypeDef GPIOC_str;
main.c: 2 warnings, 1 error
".\Objects\first.axf" - 1 Error(s), 2 Warning(s).
Target not created.
Build Time Elapsed: 00:00:02

Code :

#include <stm32f10x.h>
#include <stm32f10x_rcc.h>
#include <stm32f10x_gpio.h>
int i,j;

void GPIO_Setup()
{ RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOC , ENABLE);
GPIO_DeInit(GPIOC); GPIO_InitTypeDef GPIOC_str;
GPIO_StructInit( &GPIOC_str);
GPIOC_str.GPIO_Speed= GPIO_Speed_2MHz; GPIOC_str.GPIO_Pin= GPIO_Pin_13; GPIOC_str.GPIO_Mode= GPIO_Mode_Out_PP;

GPIO_Init( GPIOC, &GPIOC_str);

}

void delay()
{ for(i=0;i<100;i++) for(j=0;j<100;j++);
} main()
{ GPIO_Setup(); while(1) { GPIO_SetBits( GPIOC, GPIO_Pin_13); delay(); GPIO_SetBits( GPIOC, GPIO_Pin_13); delay(); }

}

Parents Reply Children