This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Check this Code for Stm32f407, Just bilnking the led4 , it is not blinking led

#include "stm32f4xx.h"

void delay_ms(uint16_t dly)
{
uint32_t f;
for(;dly>0;dly--)
{
for(f=250;f>0;f--);
for(f=250;f>0;f--);
}
}

GPIO_InitTypeDef GPIO_InitStruct;
int main()
{

RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);

GPIO_InitStruct.GPIO_Pin = GPIO_Pin_4;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOD,&GPIO_InitStruct);

GPIO_SetBits(GPIOD,GPIO_Pin_4);

while(1)
{
GPIO_SetBits(GPIOD,GPIO_Pin_4);
delay_ms(1000);

GPIO_ResetBits(GPIOD,GPIO_Pin_4);
delay_ms(1000);

}
}

Parents Reply Children
  • Or better yet, get off that bandwagon.  Trying to implement delays by way of empty loops is just about always wrong.  There are rare cases where it's the only option available, but beginners are very unlikely to run across any of those.  By the time in a developer's career they face one of them, they'll hopefully have the wisdom to know what to use when.