I am using Keil to flash the software to my stm32f407 discovery. But the software only starts working when i pullout the JLINK cable and plug it again. Why is that? Thanks.
The compiler will not optimize out __NOP() intrinsic instructions.
Change your loop from
for(uint32_t i=0;i<500000;i++){}
To
for(uint32_t i=0;i<500000;i++) { __NOP(); }