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 06:40 AM
Yes, but there's no VSSA on the TSSOP20 package.
JW
2017-08-09 05:33 AM
I'd probably make the time variable volatile so Keil doesn't optimize away the loop.
Try using the debugger to step the code. Try without a delay between them, and just step the two GPIO Set/Reset functions.
2017-08-09 01:16 PM
Hi!
void delay(unsigned int time)
{ for(time=0;time>0;time--); }time is unsigned
at first loop (time>0) is false and exits
so the delay until zero is too low
2017-08-09 02:04 PM
Additionally, make the pin as push pull in case the led terminals are swapped by mistake...
2017-08-10 12:33 AM
If not clear what Vangelis meant: when entering delay() variable time gets the parameter value (e.g. 10000), but
then for (time=0; erases this value. You may use for statement without initial setting (there is an empty semicolon!!)
like
for ( ; time>0; time--);
2017-08-10 12:56 AM
besides defining 'time' as volatile you could also add a few nops in the for-loop.
You could also set up a timer to use as delay comparator , or you can even easily use the internal systick timer and block waiting for it to reach a value.
btw:
in
for(time=0;time>0;time--);
time>0
condition will never be met as you are setting it as 0 in the loop initializer.
2017-08-10 01:54 AM
Hi,
Yes I made a mistake in delay loop. And I have corrected that. Thanks for that.
Another thing I need to make sure is that, I'm not able to add core_cm3.c file from standard peripheral STM32F0xx library provided by ST. I'm able to add only the header file.
Is it enough? If not means how to get it?
2017-08-10 04:51 AM
yes vangelis I got your point. Thanks
2017-08-10 05:34 AM
Hi
Devipriya
!!You use ARM Cortex M0 not M3.
So this file is not suitable for your MCU
2017-08-11 01:30 AM
Hi,
The above is my circuit and program. Hope added all library and everything. But I'm unable to make it work in STM32 MCU. Is there anything need to be done in addition to it?