cancel
Showing results for 
Search instead for 
Did you mean: 

LED Blinking with STM32F030F4

Posted on August 09, 2017 at 13:57

Hi,

I'm using STM32F030F4 MCU for LED blinking function. I used below code with Keil IDE.

But I'm not able to get the output.

Boot0 pin pulled low for internal flash boot loader.

Added Corresponding ST pheripheral library(gpio,misc,rcc file), CMSIS(core_cm3,system_stm32f0xx) and Startup file.

LED connected to Port A_Pin_9. I'm using ST link/v2 for programming. Do I missed anything? or any issue with code?

#include <stm32f0xx.h>

#include <stm32f0xx_gpio.h>

#include <stm32f0xx_rcc.h>

GPIO_InitTypeDef Gp;

#define GreenLED_Pin GPIO_Pin_9

#define LED_GPIO GPIOA

void delay(unsigned int time)

{

for(time=0;time>0;time--);

}

int main(void)

{

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA,ENABLE);

Gp.GPIO_Pin=GreenLED_Pin;

Gp.GPIO_Mode=GPIO_Mode_OUT;

Gp.GPIO_OType=GPIO_OType_OD;

Gp.GPIO_Speed=GPIO_Speed_Level_1;

GPIO_Init(LED_GPIO,&Gp);

while(1)

{

GPIO_SetBits(LED_GPIO,GreenLED_Pin);

delay(10000);

GPIO_ResetBits(LED_GPIO,GreenLED_Pin);

delay(10000);

}

}
16 REPLIES 16
Posted on August 11, 2017 at 11:13

In addition to that, I'm unable to debug in keil. 

Found error 65: access violation 0x40021000: no read permission

Will it create issue?

Posted on August 11, 2017 at 10:44

Use volatile for the variables in the loopdelay, so that the compiler does not optimize it out.

JW

Posted on August 11, 2017 at 14:31

Hi, 

I'm missing out something. I'm able to flash correctly, but I'm not able to blink LED?

Posted on August 11, 2017 at 12:42

Hello again!

VSSA pin seems not be connected to VSS

it is very important to connect. to ground

Posted on August 11, 2017 at 13:40

Yes, but there's no VSSA on the TSSOP20 package.

JW

Tamas Novak
Associate III
Posted on August 11, 2017 at 16:03

If your goal to see the LED blinking (notjust  checking by oscilloscope), its period time must be somewhere between 0.2 - 1 sec.  If you use delay(10000), it lasts about 40000 clock cycle, which is 1msec at 40MHz clock. You won't see any blinking at that rate.

Use systick timing instead of your delay loop:: check LL_mDelay() in stm32f0xx_ll_utils.c. 

LL_mDelay(300);   will do.

I don't understand the 'read permission error'. Address 0x40021000 is your RCC_CR register, which can be read at any time. It is usually read to check PLL_RDY bit while changing clock from default HSI to PLL. If you try to set bad PLL values (too high clock frequency) it may cause such a weird error.

Posted on August 17, 2017 at 11:22

With delay(10000), I'm not able see LED blinking. Yes Well can try with systick timing. But I tried with delay loop itself and got led blinking with delay(1000000)