#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); }}
The MDK Pack Installer offers 3 demonstrations of a Blinky implementation, see:
Also - this video (even if its from 2013) demonstrates a creation of a "Blinky Project with MDK-ARM Version 5":
https://www.youtube.com/watch?v=Pgw7-WnsBMs
(Note, an updated MDK-5 Intro is available at: https://www.youtube.com/watch?v=d_O2tu5CMbQ )
Studying the blinky examples is excellent advice. You should also reconsider how to implement delay_ms(). I suspect that an argument of 1000 is really giving you a delay of under 20ms (in which case the LED might appear to be on all the time, if a little dim, because it's blinking very quickly). Did you try setting a breakpoint in your while() loop to see if the LED is blinking at all?
Have the loop iterators be volatile so they don't optimize away.
Single step the code, or use a scope to observe a single.
Perhaps avoid arbitrary constants in delay loops.
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.