I am very new in STM32 projects and it is my first time writing a program with STM32. I used to program with AVR and now I should progress to STM32. I have a board with STM32F427VG on it without any external XTAL. I wrote the following code to make a simple LED blink:
#include "stm32f4xx_conf.h"
#include "stm32f4xx.h"
int main(void)
{
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
GPIO_InitTypeDef GPIO_InitDef; //Where GPIO_InitDef is variable to work with struct
GPIO_InitDef.GPIO_Pin = GPIO_Pin_4 ;
GPIO_InitDef.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitDef.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitDef);
GPIO_SetBits(GPIOA, GPIO_Pin_4);
GPIO_ResetBits(GPIOA, GPIO_Pin_4);
int i;
while(1)
{
GPIO_SetBits(GPIOA, GPIO_Pin_4);
for (i = 0; i < 500000; i++);
GPIO_ResetBits(GPIOA, GPIO_Pin_4);
for (i = 0; i < 500000; i++);
}
}
I use Embitz to compile my code. In order to configure the internal clock I use the following configuration:
Then I press run and then generate. Then I copy the generated system_stm32f4xx
file and replace with the default system_stm32f4xx
file in the project.
Still, I can't see any change in the LED.
I know I am very new in STM32 projects, so most likely this question is very simple for anybody. Thanks if anybody helps me to find the problem.
Best Answer
You need to do more than replace the stm32f4xx file. See http://clockspeeds.blogspot.com/2013/01/stm32f4-discovery-clock-frequency.html. In particular, you have to do some work on the startup_stm32f4xx.c file.
From that site: