Delay function for a STM32L152
In your first example, the multiplication of the seconds float by 5000000 is evaluated at each iteration, to check the end condition. Which is very very slow (and make it look like it lasts forever).

change to:

int i, max = (int)(seconds*5000000);
for(i=0; i&lt;max; i++);


This will evaluate seconds*5000000 only once, before the loop.

Also, be careful that if optimizations are enabled, depending on the compiler, any of the above sample codes may be optimized out completely (as there are no side effects the compiler will see), and you'll end up with no delay at all. To prevent the compiler doing this, you can declare i as volatile.