2017-08-09 04:57 AM
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 GPIOAvoid 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); }}Solved! Go to Solution.
2017-08-11 02:13 AM
In addition to that, I'm unable to debug in keil.
Found error 65: access violation 0x40021000: no read permission
Will it create issue?
2017-08-11 03:44 AM
Use volatile for the variables in the loopdelay, so that the compiler does not optimize it out.
JW
2017-08-11 05:31 AM
Hi,
I'm missing out something. I'm able to flash correctly, but I'm not able to blink LED?
2017-08-11 05:42 AM
Hello again!
VSSA pin seems not be connected to VSS
it is very important to connect. to ground
2017-08-11 06:40 AM
Yes, but there's no VSSA on the TSSOP20 package.
JW
2017-08-11 07:03 AM
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.
2017-08-17 02:22 AM
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)