Skip to main content
Devipriya Soundararajan
Associate
August 9, 2017
Solved

LED Blinking with STM32F030F4

  • August 9, 2017
  • 16 replies
  • 3999 views
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);

}

}
    This topic has been closed for replies.
    Best answer by waclawek.jan
    Posted on August 11, 2017 at 13:40

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

    JW

    16 replies

    Tamas Novak
    Associate III
    August 11, 2017
    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.

    Devipriya Soundararajan
    Associate
    August 17, 2017
    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)