delay function parameter minimum

Is zero a valid parameter for delay functions. just need simple yes or no. Did not see parameter minimum in reference.

If you look at the course code in wiring.c, passing in a 0 for the parameter should cause no issues.

jcebyjr:
Is zero a valid parameter for delay functions. just need simple yes or no. Did not see parameter minimum in reference.

What happened when you tried it?

...R

Robin2:
What happened when you tried it?

Easier to ask....

When in doubt . . .

void delay(unsigned long ms)
{
	uint16_t start = (uint16_t)micros();

	while (ms > 0) {
		if (((uint16_t)micros() - start) >= 1000) {
			ms--;
			start += 1000;
		}
	}
}

JimboZA:

Robin2:
What happened when you tried it?

Easier to ask....

Not really. Not at all.

AWOL:
When in doubt . . .look at the source code

...R

And the source code tells us that:

  • delay() is unsigned long so 0 is a valid argument void delay(unsigned long ms)
  • But 0 has no effect (as one would expect) because of while (ms > 0) {