M
Martin Wells
I'm doing an embedded systems project and I'm programming it as fully-
portable C89 (except of course for setting the pin values).
I need to put delays in the program, in the vicinity of 250 ms. (They
don't need to be exact).
Does C have a built-in method of putting in delays?
If not, I was thinking of defining a macro called "FLOPS" (i.e.
floating-point operations per second) and then doing something like:
void Delay(unsigned const fraction_of_full_second)
{
long unsigned amount_flop = FLOPS / fraction_of_full_second;
float x = 56.3;
do x /= x;
while (--amount_flop);
}
(Obviously I'll have to take into account the extra delay of looping
but you get the general idea)
Martin
portable C89 (except of course for setting the pin values).
I need to put delays in the program, in the vicinity of 250 ms. (They
don't need to be exact).
Does C have a built-in method of putting in delays?
If not, I was thinking of defining a macro called "FLOPS" (i.e.
floating-point operations per second) and then doing something like:
void Delay(unsigned const fraction_of_full_second)
{
long unsigned amount_flop = FLOPS / fraction_of_full_second;
float x = 56.3;
do x /= x;
while (--amount_flop);
}
(Obviously I'll have to take into account the extra delay of looping
but you get the general idea)
Martin